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
|
@contextlib.contextmanager
|
||||||
def _mock_download_collection_entries_factory(is_youtube_channel: bool, num_urls: int = 1):
|
def _mock_download_collection_entries_factory(is_youtube_channel: bool, num_urls: int = 1):
|
||||||
def _write_entries_to_working_dir(*args, **kwargs) -> List[Dict]:
|
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 [
|
return [
|
||||||
mock_entry_dict_factory(
|
mock_entry_dict_factory(
|
||||||
uid="21-1",
|
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(
|
def test_compilation_errors_missing_one(
|
||||||
self,
|
self,
|
||||||
config,
|
config,
|
||||||
|
|
@ -65,6 +86,7 @@ class TestPrebuiltTVShowPresets:
|
||||||
)
|
)
|
||||||
|
|
||||||
@pytest.mark.parametrize("is_youtube_channel", [True, False])
|
@pytest.mark.parametrize("is_youtube_channel", [True, False])
|
||||||
|
@pytest.mark.parametrize("is_many_urls", [True])
|
||||||
def test_non_collection_presets_compile(
|
def test_non_collection_presets_compile(
|
||||||
self,
|
self,
|
||||||
config,
|
config,
|
||||||
|
|
@ -74,17 +96,16 @@ class TestPrebuiltTVShowPresets:
|
||||||
media_player_preset: str,
|
media_player_preset: str,
|
||||||
tv_show_structure_preset: str,
|
tv_show_structure_preset: str,
|
||||||
is_youtube_channel: bool,
|
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,
|
media_player_preset,
|
||||||
tv_show_structure_preset,
|
tv_show_structure_preset,
|
||||||
int(is_youtube_channel),
|
int(is_youtube_channel),
|
||||||
|
"many_urls" if is_many_urls else "",
|
||||||
)
|
)
|
||||||
parent_presets = [media_player_preset, tv_show_structure_preset]
|
parent_presets = [media_player_preset, tv_show_structure_preset]
|
||||||
|
|
||||||
subscription = Subscription.from_dict(
|
|
||||||
config=config,
|
|
||||||
preset_name=subscription_name,
|
|
||||||
preset_dict = {
|
preset_dict = {
|
||||||
"preset": parent_presets,
|
"preset": parent_presets,
|
||||||
"overrides": {
|
"overrides": {
|
||||||
|
|
@ -92,21 +113,34 @@ class TestPrebuiltTVShowPresets:
|
||||||
"tv_show_name": "Best Prebuilt TV Show by Date",
|
"tv_show_name": "Best Prebuilt TV Show by Date",
|
||||||
"tv_show_directory": output_directory,
|
"tv_show_directory": output_directory,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
|
if is_many_urls:
|
||||||
|
preset_dict = dict(
|
||||||
|
preset_dict, **{"download": {"urls": [{"url": "https://url.number.2.here"}]}}
|
||||||
)
|
)
|
||||||
|
|
||||||
with mock_download_collection_entries(is_youtube_channel=is_youtube_channel):
|
subscription = Subscription.from_dict(
|
||||||
|
config=config,
|
||||||
|
preset_name=subscription_name,
|
||||||
|
preset_dict=preset_dict,
|
||||||
|
)
|
||||||
|
|
||||||
|
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)
|
transaction_log = subscription.download(dry_run=False)
|
||||||
|
|
||||||
assert_transaction_log_matches(
|
assert_transaction_log_matches(
|
||||||
output_directory=output_directory,
|
output_directory=output_directory,
|
||||||
transaction_log=transaction_log,
|
transaction_log=transaction_log,
|
||||||
transaction_log_summary_file_name=f"{expected_summary_name}.txt",
|
transaction_log_summary_file_name=f"{expected_summary_name}.txt",
|
||||||
|
regenerate_transaction_log=True,
|
||||||
)
|
)
|
||||||
assert_expected_downloads(
|
assert_expected_downloads(
|
||||||
output_directory=output_directory,
|
output_directory=output_directory,
|
||||||
dry_run=False,
|
dry_run=False,
|
||||||
expected_download_summary_file_name=f"{expected_summary_name}.json",
|
expected_download_summary_file_name=f"{expected_summary_name}.json",
|
||||||
|
regenerate_expected_download_summary=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue