From 5464598fbed92956af0db196d2a5516b7a29a095 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Thu, 18 May 2023 09:13:51 -0700 Subject: [PATCH] test that downloads --- tests/e2e/plugins/test_match_filters.py | 46 ++++++++++++++++++- .../test_match_filters_partial.json | 7 +++ .../test_match_filters_partial.txt | 15 ++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tests/resources/expected_downloads_summaries/plugins/match_filters/test_match_filters_partial.json create mode 100644 tests/resources/transaction_log_summaries/plugins/match_filters/test_match_filters_partial.txt diff --git a/tests/e2e/plugins/test_match_filters.py b/tests/e2e/plugins/test_match_filters.py index 3f9cf029..8bcfb669 100644 --- a/tests/e2e/plugins/test_match_filters.py +++ b/tests/e2e/plugins/test_match_filters.py @@ -1,4 +1,6 @@ import pytest +from expected_download import assert_expected_downloads +from expected_transaction_log import assert_transaction_log_matches from ytdl_sub.subscriptions.subscription import Subscription @@ -17,9 +19,23 @@ def preset_dict(output_directory): } +@pytest.fixture +def playlist_preset_dict(output_directory): + return { + "preset": "music_video", + "download": {"url": "https://www.youtube.com/playlist?list=PL5BC0FC26BECA5A35"}, + "output_options": {"output_directory": output_directory}, + # download the worst format so it is fast + "ytdl_options": { + "postprocessor_args": {"ffmpeg": ["-bitexact"]}, # Must add this for reproducibility + }, + "match_filters": {"filters": ["view_count > 20000"]}, + } + + class TestFileConvert: @pytest.mark.parametrize("dry_run", [True, False]) - def test_match_filters( + def test_match_filters_empty( self, music_video_config, preset_dict, @@ -34,3 +50,31 @@ class TestFileConvert: transaction_log = subscription.download(dry_run=dry_run) assert transaction_log.is_empty + + @pytest.mark.parametrize("dry_run", [True, False]) + def test_match_filters_partial( + self, + music_video_config, + playlist_preset_dict, + output_directory, + dry_run, + ): + subscription = Subscription.from_dict( + config=music_video_config, + preset_name="match_filter_test", + preset_dict=playlist_preset_dict, + ) + + transaction_log = subscription.download(dry_run=dry_run) + + summary_path = "plugins/match_filters" + assert_transaction_log_matches( + output_directory=output_directory, + transaction_log=transaction_log, + transaction_log_summary_file_name=f"{summary_path}/test_match_filters_partial.txt", + ) + assert_expected_downloads( + output_directory=output_directory, + dry_run=dry_run, + expected_download_summary_file_name=f"{summary_path}/test_match_filters_partial.json", + ) diff --git a/tests/resources/expected_downloads_summaries/plugins/match_filters/test_match_filters_partial.json b/tests/resources/expected_downloads_summaries/plugins/match_filters/test_match_filters_partial.json new file mode 100644 index 00000000..fe968a5e --- /dev/null +++ b/tests/resources/expected_downloads_summaries/plugins/match_filters/test_match_filters_partial.json @@ -0,0 +1,7 @@ +{ + ".ytdl-sub-match_filter_test-download-archive.json": "6017105735dd8fdfe18932c9c048dccf", + "Project Zombie/Project Zombie - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg": "e7830aa8a64b0cde65ba3f7e5fc56530", + "Project Zombie/Project Zombie - Jesse's Minecraft Server [Trailer - Mar.21].info.json": "ddfda0c60aafd9779da692d6c165385b", + "Project Zombie/Project Zombie - Jesse's Minecraft Server [Trailer - Mar.21].nfo": "17c303f07e9b3af77c90975f843c95bd", + "Project Zombie/Project Zombie - Jesse's Minecraft Server [Trailer - Mar.21].webm": "ad90ebef1ea6cbdb924670cdd7d1b9b9" +} \ No newline at end of file diff --git a/tests/resources/transaction_log_summaries/plugins/match_filters/test_match_filters_partial.txt b/tests/resources/transaction_log_summaries/plugins/match_filters/test_match_filters_partial.txt new file mode 100644 index 00000000..4b827ab2 --- /dev/null +++ b/tests/resources/transaction_log_summaries/plugins/match_filters/test_match_filters_partial.txt @@ -0,0 +1,15 @@ +Files created: +---------------------------------------- +{output_directory} + .ytdl-sub-match_filter_test-download-archive.json +{output_directory}/Project Zombie + Project Zombie - Jesse's Minecraft Server [Trailer - Mar.21]-thumb.jpg + Project Zombie - Jesse's Minecraft Server [Trailer - Mar.21].info.json + Project Zombie - Jesse's Minecraft Server [Trailer - Mar.21].nfo + NFO tags: + musicvideo: + album: Music Videos + artist: Project Zombie + title: Jesse's Minecraft Server [Trailer - Mar.21] + year: 2011 + Project Zombie - Jesse's Minecraft Server [Trailer - Mar.21].webm \ No newline at end of file