test
This commit is contained in:
parent
ea279be912
commit
fb5ec8f2fc
2 changed files with 45 additions and 11 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue