From fb5ec8f2fcbcf540e0b48ca9387f767f707b8ef2 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Thu, 16 Mar 2023 19:25:43 -0700 Subject: [PATCH] test --- tests/unit/prebuilt_presets/conftest.py | 2 +- .../prebuilt_presets/test_prebuilt_presets.py | 54 +++++++++++++++---- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/tests/unit/prebuilt_presets/conftest.py b/tests/unit/prebuilt_presets/conftest.py index 5c6c0f54..7b53e641 100644 --- a/tests/unit/prebuilt_presets/conftest.py +++ b/tests/unit/prebuilt_presets/conftest.py @@ -127,7 +127,7 @@ def mock_download_collection_entries( @contextlib.contextmanager def _mock_download_collection_entries_factory(is_youtube_channel: bool, num_urls: int = 1): def _write_entries_to_working_dir(*args, **kwargs) -> List[Dict]: - if num_urls == 1 or ("season.2" in kwargs["url"] and num_urls > 1): + if num_urls == 1 or ("2" in kwargs["url"] and num_urls > 1): return [ mock_entry_dict_factory( uid="21-1", diff --git a/tests/unit/prebuilt_presets/test_prebuilt_presets.py b/tests/unit/prebuilt_presets/test_prebuilt_presets.py index 4f761f95..b4d4851b 100644 --- a/tests/unit/prebuilt_presets/test_prebuilt_presets.py +++ b/tests/unit/prebuilt_presets/test_prebuilt_presets.py @@ -40,6 +40,27 @@ class TestPrebuiltTVShowPresets: }, ) + def test_compilation_many_urls( + self, + config, + media_player_preset: str, + tv_show_structure_preset: str, + ): + parent_presets: List[str] = [media_player_preset, tv_show_structure_preset] + _ = Subscription.from_dict( + config=config, + preset_name="preset_test", + preset_dict={ + "preset": parent_presets, + "download": {"urls": [{"url": "https://second.url"}]}, + "overrides": { + "url": "https://your.name.here", + "tv_show_name": "test-compile", + "tv_show_directory": "output_dir", + }, + }, + ) + def test_compilation_errors_missing_one( self, config, @@ -65,6 +86,7 @@ class TestPrebuiltTVShowPresets: ) @pytest.mark.parametrize("is_youtube_channel", [True, False]) + @pytest.mark.parametrize("is_many_urls", [True]) def test_non_collection_presets_compile( self, config, @@ -74,39 +96,51 @@ class TestPrebuiltTVShowPresets: media_player_preset: str, tv_show_structure_preset: str, is_youtube_channel: bool, + is_many_urls: bool, ): - expected_summary_name = "unit/{}/{}/is_yt_{}".format( + expected_summary_name = "unit/{}/{}/is_yt_{}{}".format( media_player_preset, tv_show_structure_preset, int(is_youtube_channel), + "many_urls" if is_many_urls else "", ) parent_presets = [media_player_preset, tv_show_structure_preset] + preset_dict = { + "preset": parent_presets, + "overrides": { + "url": "https://your.name.here", + "tv_show_name": "Best Prebuilt TV Show by Date", + "tv_show_directory": output_directory, + }, + } + if is_many_urls: + preset_dict = dict( + preset_dict, **{"download": {"urls": [{"url": "https://url.number.2.here"}]}} + ) + subscription = Subscription.from_dict( config=config, preset_name=subscription_name, - preset_dict={ - "preset": parent_presets, - "overrides": { - "url": "https://your.name.here", - "tv_show_name": "Best Prebuilt TV Show by Date", - "tv_show_directory": output_directory, - }, - }, + preset_dict=preset_dict, ) - with mock_download_collection_entries(is_youtube_channel=is_youtube_channel): + with mock_download_collection_entries( + is_youtube_channel=is_youtube_channel, num_urls=2 if is_many_urls else 1 + ): transaction_log = subscription.download(dry_run=False) assert_transaction_log_matches( output_directory=output_directory, transaction_log=transaction_log, transaction_log_summary_file_name=f"{expected_summary_name}.txt", + regenerate_transaction_log=True, ) assert_expected_downloads( output_directory=output_directory, dry_run=False, expected_download_summary_file_name=f"{expected_summary_name}.json", + regenerate_expected_download_summary=True, )