From c186af2adc3ee91bffb0ec61c8a3be2d3906b246 Mon Sep 17 00:00:00 2001 From: jbannon Date: Mon, 4 Jul 2022 07:59:59 +0000 Subject: [PATCH] all tests now have files except rolling recent --- tests/e2e/expected_download.py | 12 -- ...full_channel.txt => test_channel_full.txt} | 0 .../test_channel_no_additional_downloads.txt | 9 ++ .../test_channel_recent.txt | 52 ++++++++ .../test_merge_playlist.txt | 15 +++ .../test_playlist.txt | 30 +++++ .../test_soundcloud_discography.txt | 123 ++++++++++++++++++ .../test_split_video.txt | 62 +++++++++ .../transaction_log_summaries/test_video.txt | 11 ++ .../soundcloud/test_soundcloud_discography.py | 20 +-- .../youtube/test_channel_as_kodi_tv_show.py | 94 ++++++------- tests/e2e/youtube/test_merge_playlist.py | 19 +-- .../test_playlist_as_kodi_music_videos.py | 50 +++---- tests/e2e/youtube/test_split_video.py | 17 ++- 14 files changed, 408 insertions(+), 106 deletions(-) rename tests/e2e/resources/transaction_log_summaries/{test_channel_as_kodi_tv_show__full_channel.txt => test_channel_full.txt} (100%) create mode 100644 tests/e2e/resources/transaction_log_summaries/test_channel_no_additional_downloads.txt create mode 100644 tests/e2e/resources/transaction_log_summaries/test_channel_recent.txt create mode 100644 tests/e2e/resources/transaction_log_summaries/test_merge_playlist.txt create mode 100644 tests/e2e/resources/transaction_log_summaries/test_playlist.txt create mode 100644 tests/e2e/resources/transaction_log_summaries/test_soundcloud_discography.txt create mode 100644 tests/e2e/resources/transaction_log_summaries/test_split_video.txt create mode 100644 tests/e2e/resources/transaction_log_summaries/test_video.txt diff --git a/tests/e2e/expected_download.py b/tests/e2e/expected_download.py index 7894c847..d327444c 100644 --- a/tests/e2e/expected_download.py +++ b/tests/e2e/expected_download.py @@ -6,7 +6,6 @@ from typing import List from typing import Optional from typing import Union -from ytdl_sub.utils.file_handler import FileHandlerTransactionLog from ytdl_sub.utils.file_handler import FileMetadata @@ -72,14 +71,3 @@ class ExpectedDownloads: f"MD5 hash for {str(expected_download.path)} does not match: " f"{md5_hash} != {expected_md5_hash}" ) - - def assert_dry_run_files_logged(self, transaction_log: FileHandlerTransactionLog): - assert ( - len(transaction_log.files_created) == self.file_count - ), "Mismatch in number of created files" - - for expected_download in self.expected_downloads: - expected_path = str(expected_download.path) - assert ( - expected_path in transaction_log.files_created - ), f"Expected {expected_path} to be a file but it is not" diff --git a/tests/e2e/resources/transaction_log_summaries/test_channel_as_kodi_tv_show__full_channel.txt b/tests/e2e/resources/transaction_log_summaries/test_channel_full.txt similarity index 100% rename from tests/e2e/resources/transaction_log_summaries/test_channel_as_kodi_tv_show__full_channel.txt rename to tests/e2e/resources/transaction_log_summaries/test_channel_full.txt diff --git a/tests/e2e/resources/transaction_log_summaries/test_channel_no_additional_downloads.txt b/tests/e2e/resources/transaction_log_summaries/test_channel_no_additional_downloads.txt new file mode 100644 index 00000000..fbf235cf --- /dev/null +++ b/tests/e2e/resources/transaction_log_summaries/test_channel_no_additional_downloads.txt @@ -0,0 +1,9 @@ +Files created in 'FILL_IN' +---------------------------------------- +.ytdl-sub-pz-download-archive.json +fanart.jpg +poster.jpg +tvshow.nfo + NFO tags: + tvshow: + title: Project / Zombie \ No newline at end of file diff --git a/tests/e2e/resources/transaction_log_summaries/test_channel_recent.txt b/tests/e2e/resources/transaction_log_summaries/test_channel_recent.txt new file mode 100644 index 00000000..9c0c6273 --- /dev/null +++ b/tests/e2e/resources/transaction_log_summaries/test_channel_recent.txt @@ -0,0 +1,52 @@ +Files created in 'FILL_IN' +---------------------------------------- +.ytdl-sub-pz-download-archive.json +Season 2018/s2018.e1029 - Jesse's Minecraft Server _ Teaser Trailer.jpg +Season 2018/s2018.e1029 - Jesse's Minecraft Server _ Teaser Trailer.mp4 +Season 2018/s2018.e1029 - Jesse's Minecraft Server _ Teaser Trailer.nfo + NFO tags: + episodedetails: + aired: 2018-10-29 + episode: 1029 + plot: + See the full trailer here: https://youtu.be/LN2e6idGluI + Discord: https://discord.gg/BQN7SSe + Website: https://www.projectzombie.net/ + + It has been about six years since the glory days of the original RP server. Hope to see many familiar faces in the revival of our great server. + + Credits: + ALISON - Space Echo + https://www.youtube.com/watch?v=lPldcjlv3_Y + season: 2018 + title: Jesse's Minecraft Server | Teaser Trailer + year: 2018 +Season 2018/s2018.e1102 - Jesse's Minecraft Server _ IP mc.jesse.id.jpg +Season 2018/s2018.e1102 - Jesse's Minecraft Server _ IP mc.jesse.id.mp4 +Season 2018/s2018.e1102 - Jesse's Minecraft Server _ IP mc.jesse.id.nfo + NFO tags: + episodedetails: + aired: 2018-11-02 + episode: 1102 + plot: + IP: mc.jesse.id + Live Map: http://mc.jesse.id:8123 + Discord: https://discord.gg/BQN7SSe + Website: https://www.projectzombie.net/ + + It has been about six years since the glory days of the original RP server. Hope to see many familiar faces in the revival of our great server. + + The MC version is 1.13.x AND/OR 1.12.x + + Credits: + ALISON - Space Echo + https://www.youtube.com/watch?v=lPldcjlv3_Y + season: 2018 + title: Jesse's Minecraft Server | IP mc.jesse.id + year: 2018 +fanart.jpg +poster.jpg +tvshow.nfo + NFO tags: + tvshow: + title: Project / Zombie \ No newline at end of file diff --git a/tests/e2e/resources/transaction_log_summaries/test_merge_playlist.txt b/tests/e2e/resources/transaction_log_summaries/test_merge_playlist.txt new file mode 100644 index 00000000..69ac1806 --- /dev/null +++ b/tests/e2e/resources/transaction_log_summaries/test_merge_playlist.txt @@ -0,0 +1,15 @@ +Files created in 'FILL_IN' +---------------------------------------- +JMC - Jesse's Minecraft Server.jpg +JMC - Jesse's Minecraft Server.mkv + Timestamps of playlist videos in the merged file: + 0:00: Jesse's Minecraft Server [Trailer - Feb.1] + 5:23: Jesse's Minecraft Server [Trailer - Feb.27] + 9:23: Jesse's Minecraft Server [Trailer - Mar.21] +JMC - Jesse's Minecraft Server.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: JMC + title: Jesse's Minecraft Server + year: 2011 \ No newline at end of file diff --git a/tests/e2e/resources/transaction_log_summaries/test_playlist.txt b/tests/e2e/resources/transaction_log_summaries/test_playlist.txt new file mode 100644 index 00000000..6cc5f180 --- /dev/null +++ b/tests/e2e/resources/transaction_log_summaries/test_playlist.txt @@ -0,0 +1,30 @@ +Files created in 'FILL_IN' +---------------------------------------- +.ytdl-sub-jmc-download-archive.json +JMC - Jesse's Minecraft Server [Trailer - Feb.1].jpg +JMC - Jesse's Minecraft Server [Trailer - Feb.1].mp4 +JMC - Jesse's Minecraft Server [Trailer - Feb.1].nfo + NFO tags: + musicvideo: + album: Music Videos + artist: JMC + title: Jesse's Minecraft Server [Trailer - Feb.1] + year: 2011 +JMC - Jesse's Minecraft Server [Trailer - Feb.27].jpg +JMC - Jesse's Minecraft Server [Trailer - Feb.27].mp4 +JMC - Jesse's Minecraft Server [Trailer - Feb.27].nfo + NFO tags: + musicvideo: + album: Music Videos + artist: JMC + title: Jesse's Minecraft Server [Trailer - Feb.27] + year: 2011 +JMC - Jesse's Minecraft Server [Trailer - Mar.21].jpg +JMC - Jesse's Minecraft Server [Trailer - Mar.21].mp4 +JMC - Jesse's Minecraft Server [Trailer - Mar.21].nfo + NFO tags: + musicvideo: + album: Music Videos + artist: JMC + title: Jesse's Minecraft Server [Trailer - Mar.21] + year: 2011 \ No newline at end of file diff --git a/tests/e2e/resources/transaction_log_summaries/test_soundcloud_discography.txt b/tests/e2e/resources/transaction_log_summaries/test_soundcloud_discography.txt new file mode 100644 index 00000000..44ca2eae --- /dev/null +++ b/tests/e2e/resources/transaction_log_summaries/test_soundcloud_discography.txt @@ -0,0 +1,123 @@ +Files created in 'FILL_IN' +---------------------------------------- +.ytdl-sub-jb-download-archive.json +j_b/[2021] Baby Santana's Dorian Groove/01 - Baby Santana's Dorian Groove.mp3 + Music Tags: + album: Baby Santana's Dorian Groove + albumartist: j_b + artist: j_b + genre: Unset + title: Baby Santana's Dorian Groove + track: 1 + year: 2021 +j_b/[2021] Baby Santana's Dorian Groove/folder.jpg +j_b/[2021] Purple Clouds/01 - Purple Clouds.mp3 + Music Tags: + album: Purple Clouds + albumartist: j_b + artist: j_b + genre: Unset + title: Purple Clouds + track: 1 + year: 2021 +j_b/[2021] Purple Clouds/folder.jpg +j_b/[2022] Acoustic Treats/01 - 20160426 184214.mp3 + Music Tags: + album: Acoustic Treats + albumartist: j_b + artist: j_b + genre: Unset + title: 20160426 184214 + track: 1 + year: 2022 +j_b/[2022] Acoustic Treats/02 - 20160502 123150.mp3 + Music Tags: + album: Acoustic Treats + albumartist: j_b + artist: j_b + genre: Unset + title: 20160502 123150 + track: 2 + year: 2022 +j_b/[2022] Acoustic Treats/03 - 20160504 143832.mp3 + Music Tags: + album: Acoustic Treats + albumartist: j_b + artist: j_b + genre: Unset + title: 20160504 143832 + track: 3 + year: 2022 +j_b/[2022] Acoustic Treats/04 - 20160601 221234.mp3 + Music Tags: + album: Acoustic Treats + albumartist: j_b + artist: j_b + genre: Unset + title: 20160601 221234 + track: 4 + year: 2022 +j_b/[2022] Acoustic Treats/05 - 20160601 222440.mp3 + Music Tags: + album: Acoustic Treats + albumartist: j_b + artist: j_b + genre: Unset + title: 20160601 222440 + track: 5 + year: 2022 +j_b/[2022] Acoustic Treats/06 - 20170604 190236.mp3 + Music Tags: + album: Acoustic Treats + albumartist: j_b + artist: j_b + genre: Unset + title: 20170604 190236 + track: 6 + year: 2022 +j_b/[2022] Acoustic Treats/07 - 20170612 193646.mp3 + Music Tags: + album: Acoustic Treats + albumartist: j_b + artist: j_b + genre: Unset + title: 20170612 193646 + track: 7 + year: 2022 +j_b/[2022] Acoustic Treats/08 - 20170628 215206.mp3 + Music Tags: + album: Acoustic Treats + albumartist: j_b + artist: j_b + genre: Unset + title: 20170628 215206 + track: 8 + year: 2022 +j_b/[2022] Acoustic Treats/09 - Finding Home.mp3 + Music Tags: + album: Acoustic Treats + albumartist: j_b + artist: j_b + genre: Unset + title: Finding Home + track: 9 + year: 2022 +j_b/[2022] Acoustic Treats/10 - Shallow Water WIP.mp3 + Music Tags: + album: Acoustic Treats + albumartist: j_b + artist: j_b + genre: Unset + title: Shallow Water WIP + track: 10 + year: 2022 +j_b/[2022] Acoustic Treats/11 - Untold History.mp3 + Music Tags: + album: Acoustic Treats + albumartist: j_b + artist: j_b + genre: Unset + title: Untold History + track: 11 + year: 2022 +j_b/[2022] Acoustic Treats/folder.jpg \ No newline at end of file diff --git a/tests/e2e/resources/transaction_log_summaries/test_split_video.txt b/tests/e2e/resources/transaction_log_summaries/test_split_video.txt new file mode 100644 index 00000000..565862d8 --- /dev/null +++ b/tests/e2e/resources/transaction_log_summaries/test_split_video.txt @@ -0,0 +1,62 @@ +Files created in 'FILL_IN' +---------------------------------------- +Project Zombie - 1-6.Intro.mp4 + 0:00 - 0:10 +Project Zombie - 2-6.Part 1.mp4 + 0:10 - 0:20 +Project Zombie - 3-6.Part 2.mp4 + 0:20 - 0:30 +Project Zombie - 4-6.Part 3.mp4 + 0:30 - 0:40 +Project Zombie - 5-6.Part 4.mp4 + 0:40 - 1:01 +Project Zombie - 6-6.Part 5.mp4 + 1:01 - 1:28 +Project Zombie - Intro.jpg +Project Zombie - Intro.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: Project Zombie + title: Intro + year: 2010 +Project Zombie - Part 1.jpg +Project Zombie - Part 1.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: Project Zombie + title: Part 1 + year: 2010 +Project Zombie - Part 2.jpg +Project Zombie - Part 2.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: Project Zombie + title: Part 2 + year: 2010 +Project Zombie - Part 3.jpg +Project Zombie - Part 3.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: Project Zombie + title: Part 3 + year: 2010 +Project Zombie - Part 4.jpg +Project Zombie - Part 4.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: Project Zombie + title: Part 4 + year: 2010 +Project Zombie - Part 5.jpg +Project Zombie - Part 5.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: Project Zombie + title: Part 5 + year: 2010 \ No newline at end of file diff --git a/tests/e2e/resources/transaction_log_summaries/test_video.txt b/tests/e2e/resources/transaction_log_summaries/test_video.txt new file mode 100644 index 00000000..62cf64f7 --- /dev/null +++ b/tests/e2e/resources/transaction_log_summaries/test_video.txt @@ -0,0 +1,11 @@ +Files created in 'FILL_IN' +---------------------------------------- +JMC - Oblivion Mod 'Falcor' p.1.jpg +JMC - Oblivion Mod 'Falcor' p.1.mp4 +JMC - Oblivion Mod 'Falcor' p.1.nfo + NFO tags: + musicvideo: + album: Music Videos + artist: JMC + title: Oblivion Mod "Falcor" p.1 + year: 2010 \ No newline at end of file diff --git a/tests/e2e/soundcloud/test_soundcloud_discography.py b/tests/e2e/soundcloud/test_soundcloud_discography.py index 4e567003..5ae24359 100644 --- a/tests/e2e/soundcloud/test_soundcloud_discography.py +++ b/tests/e2e/soundcloud/test_soundcloud_discography.py @@ -3,6 +3,7 @@ from pathlib import Path import pytest from e2e.expected_download import ExpectedDownloadFile from e2e.expected_download import ExpectedDownloads +from e2e.expected_transaction_log import assert_transaction_log_matches from ytdl_sub.config.config_file import ConfigFile from ytdl_sub.config.preset import Preset @@ -93,14 +94,15 @@ class TestSoundcloudDiscography: expected md5 file hashes. """ + @pytest.mark.parametrize("dry_run", [True, False]) def test_discography_download( - self, discography_subscription, expected_discography_download, output_directory + self, discography_subscription, expected_discography_download, output_directory, dry_run ): - discography_subscription.download() - expected_discography_download.assert_files_exist(relative_directory=output_directory) - - def test_discography_dry_run( - self, discography_subscription, expected_discography_download, output_directory - ): - transaction_log = discography_subscription.download(dry_run=True) - expected_discography_download.assert_dry_run_files_logged(transaction_log=transaction_log) + transaction_log = discography_subscription.download(dry_run=dry_run) + assert_transaction_log_matches( + output_directory=output_directory, + transaction_log=transaction_log, + transaction_log_summary_file_name="test_soundcloud_discography.txt", + ) + if not dry_run: + expected_discography_download.assert_files_exist(relative_directory=output_directory) diff --git a/tests/e2e/youtube/test_channel_as_kodi_tv_show.py b/tests/e2e/youtube/test_channel_as_kodi_tv_show.py index 0d8677ca..d079612a 100644 --- a/tests/e2e/youtube/test_channel_as_kodi_tv_show.py +++ b/tests/e2e/youtube/test_channel_as_kodi_tv_show.py @@ -293,71 +293,71 @@ class TestChannelAsKodiTvShow: expected md5 file hashes. """ + @pytest.mark.parametrize("dry_run", [True, False]) def test_full_channel_download( - self, full_channel_subscription, expected_full_channel_download, output_directory + self, full_channel_subscription, expected_full_channel_download, output_directory, dry_run ): - full_channel_subscription.download() - expected_full_channel_download.assert_files_exist(relative_directory=output_directory) - - def test_full_channel_dry_run( - self, full_channel_subscription, expected_full_channel_download, output_directory - ): - transaction_log = full_channel_subscription.download(dry_run=True) + transaction_log = full_channel_subscription.download(dry_run=dry_run) assert_transaction_log_matches( output_directory=output_directory, transaction_log=transaction_log, - transaction_log_summary_file_name="test_channel_as_kodi_tv_show__full_channel.txt", + transaction_log_summary_file_name="test_channel_full.txt", ) + if not dry_run: + expected_full_channel_download.assert_files_exist(relative_directory=output_directory) + @pytest.mark.parametrize("dry_run", [True, False]) def test_recent_channel_download( - self, recent_channel_subscription, expected_recent_channel_download, output_directory + self, + recent_channel_subscription, + expected_recent_channel_download, + output_directory, + dry_run, ): - recent_channel_subscription.download() - expected_recent_channel_download.assert_files_exist(relative_directory=output_directory) - - # try downloading again, ensure nothing more was downloaded - with assert_debug_log( - logger=ytdl_sub.downloaders.downloader.logger, - expected_message="ExistingVideoReached, stopping additional downloads", - ): - recent_channel_subscription.download() + transaction_log = recent_channel_subscription.download(dry_run=dry_run) + assert_transaction_log_matches( + output_directory=output_directory, + transaction_log=transaction_log, + transaction_log_summary_file_name="test_channel_recent.txt", + ) + if not dry_run: expected_recent_channel_download.assert_files_exist(relative_directory=output_directory) - def test_recent_channel_dry_run( - self, recent_channel_subscription, expected_recent_channel_download, output_directory - ): - transaction_log = recent_channel_subscription.download(dry_run=True) - expected_recent_channel_download.assert_dry_run_files_logged( - transaction_log=transaction_log - ) + # try downloading again, ensure nothing more was downloaded + with assert_debug_log( + logger=ytdl_sub.downloaders.downloader.logger, + expected_message="ExistingVideoReached, stopping additional downloads", + ): + transaction_log = recent_channel_subscription.download() + assert_transaction_log_matches( + output_directory=output_directory, + transaction_log=transaction_log, + transaction_log_summary_file_name="test_channel_no_additional_downloads.txt", + ) + expected_recent_channel_download.assert_files_exist( + relative_directory=output_directory + ) + @pytest.mark.parametrize("dry_run", [True, False]) def test_recent_channel_download__no_vids_in_range( self, recent_channel_no_vids_in_range_subscription, expected_recent_channel_no_vids_in_range_download, output_directory, + dry_run, ): - recent_channel_no_vids_in_range_subscription.download() - expected_recent_channel_no_vids_in_range_download.assert_files_exist( - relative_directory=output_directory - ) - - # Try again, make sure its the same - recent_channel_no_vids_in_range_subscription.download() - expected_recent_channel_no_vids_in_range_download.assert_files_exist( - relative_directory=output_directory - ) - - def test_recent_channel_dry_run__no_vids_in_range( - self, - recent_channel_no_vids_in_range_subscription, - expected_recent_channel_no_vids_in_range_download, - output_directory, - ): - transaction_log = recent_channel_no_vids_in_range_subscription.download(dry_run=True) - expected_recent_channel_no_vids_in_range_download.assert_dry_run_files_logged( - transaction_log=transaction_log - ) + # Run twice, ensure nothing changes between runs + for _ in range(2): + transaction_log = recent_channel_no_vids_in_range_subscription.download(dry_run=dry_run) + assert_transaction_log_matches( + output_directory=output_directory, + transaction_log=transaction_log, + transaction_log_summary_file_name="test_channel_no_additional_downloads.txt", + ) + if not dry_run: + expected_recent_channel_no_vids_in_range_download.assert_files_exist( + relative_directory=output_directory + ) def test_rolling_recent_channel_download( self, diff --git a/tests/e2e/youtube/test_merge_playlist.py b/tests/e2e/youtube/test_merge_playlist.py index b1265875..dacfb31c 100644 --- a/tests/e2e/youtube/test_merge_playlist.py +++ b/tests/e2e/youtube/test_merge_playlist.py @@ -3,6 +3,7 @@ from pathlib import Path import pytest from e2e.expected_download import ExpectedDownloadFile from e2e.expected_download import ExpectedDownloads +from e2e.expected_transaction_log import assert_transaction_log_matches from ytdl_sub.config.config_file import ConfigFile from ytdl_sub.config.preset import Preset @@ -81,14 +82,16 @@ class TestYoutubeMergePlaylist: files exist and have the expected md5 file hashes. """ + @pytest.mark.parametrize("dry_run", [True, False]) def test_merge_playlist_download( - self, playlist_subscription, expected_playlist_download, output_directory + self, playlist_subscription, expected_playlist_download, output_directory, dry_run ): - playlist_subscription.download() - expected_playlist_download.assert_files_exist(relative_directory=output_directory) + transaction_log = playlist_subscription.download() + assert_transaction_log_matches( + output_directory=output_directory, + transaction_log=transaction_log, + transaction_log_summary_file_name="test_merge_playlist.txt", + ) - def test_merge_playlist_dry_run( - self, playlist_subscription, expected_playlist_download, output_directory - ): - transaction_log = playlist_subscription.download(dry_run=True) - expected_playlist_download.assert_dry_run_files_logged(transaction_log=transaction_log) + if not dry_run: + expected_playlist_download.assert_files_exist(relative_directory=output_directory) diff --git a/tests/e2e/youtube/test_playlist_as_kodi_music_videos.py b/tests/e2e/youtube/test_playlist_as_kodi_music_videos.py index f0434226..83a6491e 100644 --- a/tests/e2e/youtube/test_playlist_as_kodi_music_videos.py +++ b/tests/e2e/youtube/test_playlist_as_kodi_music_videos.py @@ -5,6 +5,7 @@ import pytest from conftest import assert_debug_log from e2e.expected_download import ExpectedDownloadFile from e2e.expected_download import ExpectedDownloads +from e2e.expected_transaction_log import assert_transaction_log_matches import ytdl_sub.downloaders.downloader from ytdl_sub.config.config_file import ConfigFile @@ -135,36 +136,37 @@ class TestPlaylistAsKodiMusicVideo: files exist and have the expected md5 file hashes. """ + @pytest.mark.parametrize("dry_run", [True, False]) def test_playlist_download( - self, playlist_subscription, expected_playlist_download, output_directory + self, playlist_subscription, expected_playlist_download, output_directory, dry_run ): - playlist_subscription.download() - expected_playlist_download.assert_files_exist(relative_directory=output_directory) + transaction_log = playlist_subscription.download() + assert_transaction_log_matches( + output_directory=output_directory, + transaction_log=transaction_log, + transaction_log_summary_file_name="test_playlist.txt", + ) - # After the playlist is downloaded, ensure another invocation will hit ExistingVideoReached - with assert_debug_log( - logger=ytdl_sub.downloaders.downloader.logger, - expected_message="ExistingVideoReached, stopping additional downloads", - ): - playlist_subscription.download() + if not dry_run: expected_playlist_download.assert_files_exist(relative_directory=output_directory) - def test_playlist_dry_run( - self, playlist_subscription, expected_playlist_download, output_directory - ): - file_transaction_log = playlist_subscription.download(dry_run=True) - expected_playlist_download.assert_dry_run_files_logged(transaction_log=file_transaction_log) + # Ensure another invocation will hit ExistingVideoReached + with assert_debug_log( + logger=ytdl_sub.downloaders.downloader.logger, + expected_message="ExistingVideoReached, stopping additional downloads", + ): + playlist_subscription.download() + expected_playlist_download.assert_files_exist(relative_directory=output_directory) + @pytest.mark.parametrize("dry_run", [True, False]) def test_single_video_download( - self, single_video_subscription, expected_single_video_download, output_directory + self, single_video_subscription, expected_single_video_download, output_directory, dry_run ): - single_video_subscription.download() - expected_single_video_download.assert_files_exist(relative_directory=output_directory) - - def test_single_video_dry_run( - self, single_video_subscription, expected_single_video_download, output_directory - ): - file_transaction_log = single_video_subscription.download(dry_run=True) - expected_single_video_download.assert_dry_run_files_logged( - transaction_log=file_transaction_log + transaction_log = single_video_subscription.download() + assert_transaction_log_matches( + output_directory=output_directory, + transaction_log=transaction_log, + transaction_log_summary_file_name="test_video.txt", ) + if not dry_run: + expected_single_video_download.assert_files_exist(relative_directory=output_directory) diff --git a/tests/e2e/youtube/test_split_video.py b/tests/e2e/youtube/test_split_video.py index 30771d59..4d2129c2 100644 --- a/tests/e2e/youtube/test_split_video.py +++ b/tests/e2e/youtube/test_split_video.py @@ -6,6 +6,7 @@ import pytest from conftest import assert_debug_log from e2e.expected_download import ExpectedDownloadFile from e2e.expected_download import ExpectedDownloads +from e2e.expected_transaction_log import assert_transaction_log_matches import ytdl_sub.downloaders.downloader from ytdl_sub.config.config_file import ConfigFile @@ -120,12 +121,16 @@ class TestPlaylistAsKodiMusicVideo: files exist and have the expected md5 file hashes. """ + @pytest.mark.parametrize("dry_run", [True, False]) def test_split_video_download( - self, single_video_subscription, expected_single_video_download, output_directory + self, single_video_subscription, expected_single_video_download, output_directory, dry_run ): - single_video_subscription.download() - expected_single_video_download.assert_files_exist(relative_directory=output_directory) + transaction_log = single_video_subscription.download() + assert_transaction_log_matches( + output_directory=output_directory, + transaction_log=transaction_log, + transaction_log_summary_file_name="test_split_video.txt", + ) - def test_split_video_dry_run(self, single_video_subscription, expected_single_video_download): - transaction_log = single_video_subscription.download(dry_run=True) - expected_single_video_download.assert_dry_run_files_logged(transaction_log=transaction_log) + if not dry_run: + expected_single_video_download.assert_files_exist(relative_directory=output_directory)