better playlist test
Browse files- tests/test_cli.py +10 -1
tests/test_cli.py
CHANGED
|
@@ -194,14 +194,23 @@ def test_download_by_resolution_flag(youtube, download_by_resolution):
|
|
| 194 |
download_by_resolution.assert_called()
|
| 195 |
|
| 196 |
|
|
|
|
| 197 |
@mock.patch("pytube.cli.Playlist")
|
| 198 |
-
|
|
|
|
|
|
|
| 199 |
cli.safe_filename = MagicMock(return_value="safe_title")
|
| 200 |
parser = argparse.ArgumentParser()
|
| 201 |
args = parse_args(parser, ["https://www.youtube.com/playlist?list=PLyn"])
|
| 202 |
cli._parse_args = MagicMock(return_value=args)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
cli.main()
|
|
|
|
| 204 |
playlist.assert_called()
|
|
|
|
| 205 |
|
| 206 |
|
| 207 |
@mock.patch("pytube.cli.YouTube")
|
|
|
|
| 194 |
download_by_resolution.assert_called()
|
| 195 |
|
| 196 |
|
| 197 |
+
@mock.patch("pytube.cli.YouTube")
|
| 198 |
@mock.patch("pytube.cli.Playlist")
|
| 199 |
+
@mock.patch("pytube.cli._perform_args_on_youtube")
|
| 200 |
+
def test_download_with_playlist(perform_args_on_youtube, playlist, youtube):
|
| 201 |
+
# Given
|
| 202 |
cli.safe_filename = MagicMock(return_value="safe_title")
|
| 203 |
parser = argparse.ArgumentParser()
|
| 204 |
args = parse_args(parser, ["https://www.youtube.com/playlist?list=PLyn"])
|
| 205 |
cli._parse_args = MagicMock(return_value=args)
|
| 206 |
+
videos = [youtube]
|
| 207 |
+
playlist_instance = playlist.return_value
|
| 208 |
+
playlist_instance.videos = videos
|
| 209 |
+
# When
|
| 210 |
cli.main()
|
| 211 |
+
# Then
|
| 212 |
playlist.assert_called()
|
| 213 |
+
perform_args_on_youtube.assert_called_with(youtube, args)
|
| 214 |
|
| 215 |
|
| 216 |
@mock.patch("pytube.cli.YouTube")
|