test
This commit is contained in:
parent
d8e416416a
commit
1c7088d8bf
1 changed files with 57 additions and 6 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
import copy
|
import copy
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import List
|
from typing import List
|
||||||
|
from typing import Optional
|
||||||
|
from typing import Tuple
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from expected_download import assert_expected_downloads
|
from expected_download import assert_expected_downloads
|
||||||
|
|
@ -16,18 +18,56 @@ from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
from ytdl_sub.utils.exceptions import ValidationException
|
from ytdl_sub.utils.exceptions import ValidationException
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("media_player_preset", TvShowByDateOldPresets.preset_names)
|
def _tv_show_by_date_combos() -> List[Tuple[None, str, str]]:
|
||||||
|
combos: List[Tuple[None, str, str]] = []
|
||||||
|
|
||||||
|
for media_player_preset in TvShowByDateOldPresets.preset_names:
|
||||||
|
for tv_show_structure_preset in TvShowByDateEpisodeFormattingPresets.preset_names:
|
||||||
|
combos.append((None, media_player_preset, tv_show_structure_preset))
|
||||||
|
|
||||||
|
return combos
|
||||||
|
|
||||||
|
|
||||||
|
def _tv_show_by_date_parent_presets(
|
||||||
|
all_in_one_preset: Optional[str],
|
||||||
|
media_player_preset: str,
|
||||||
|
tv_show_structured_preset: str,
|
||||||
|
) -> List[str]:
|
||||||
|
"""Hack to include the all_in_one presets in this test suite"""
|
||||||
|
if all_in_one_preset is not None:
|
||||||
|
return [all_in_one_preset]
|
||||||
|
return [
|
||||||
|
media_player_preset,
|
||||||
|
tv_show_structured_preset,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"tv_show_structure_preset", TvShowByDateEpisodeFormattingPresets.preset_names
|
"all_in_one_preset, media_player_preset, tv_show_structure_preset",
|
||||||
|
[
|
||||||
|
# Test that the all-in-ones are equivalent to using the two underlying ones
|
||||||
|
("Kodi TV Show by Date", "kodi_tv_show_by_date", "season_by_year__episode_by_month_day"),
|
||||||
|
(
|
||||||
|
"Jellyfin TV Show by Date",
|
||||||
|
"jellyfin_tv_show_by_date",
|
||||||
|
"season_by_year__episode_by_month_day",
|
||||||
|
),
|
||||||
|
("Plex TV Show by Date", "plex_tv_show_by_date", "season_by_year__episode_by_month_day"),
|
||||||
|
*_tv_show_by_date_combos(),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
class TestPrebuiltTVShowPresets:
|
class TestPrebuiltTVShowPresets:
|
||||||
def test_compilation(
|
def test_compilation(
|
||||||
self,
|
self,
|
||||||
config,
|
config,
|
||||||
|
all_in_one_preset: Optional[str],
|
||||||
media_player_preset: str,
|
media_player_preset: str,
|
||||||
tv_show_structure_preset: str,
|
tv_show_structure_preset: str,
|
||||||
):
|
):
|
||||||
parent_presets: List[str] = [media_player_preset, tv_show_structure_preset]
|
parent_presets = _tv_show_by_date_parent_presets(
|
||||||
|
all_in_one_preset, media_player_preset, tv_show_structure_preset
|
||||||
|
)
|
||||||
|
|
||||||
_ = Subscription.from_dict(
|
_ = Subscription.from_dict(
|
||||||
config=config,
|
config=config,
|
||||||
preset_name="preset_test",
|
preset_name="preset_test",
|
||||||
|
|
@ -44,10 +84,14 @@ class TestPrebuiltTVShowPresets:
|
||||||
def test_compilation_many_urls(
|
def test_compilation_many_urls(
|
||||||
self,
|
self,
|
||||||
config,
|
config,
|
||||||
|
all_in_one_preset: Optional[str],
|
||||||
media_player_preset: str,
|
media_player_preset: str,
|
||||||
tv_show_structure_preset: str,
|
tv_show_structure_preset: str,
|
||||||
):
|
):
|
||||||
parent_presets: List[str] = [media_player_preset, tv_show_structure_preset]
|
parent_presets = _tv_show_by_date_parent_presets(
|
||||||
|
all_in_one_preset, media_player_preset, tv_show_structure_preset
|
||||||
|
)
|
||||||
|
|
||||||
_ = Subscription.from_dict(
|
_ = Subscription.from_dict(
|
||||||
config=config,
|
config=config,
|
||||||
preset_name="preset_test",
|
preset_name="preset_test",
|
||||||
|
|
@ -65,10 +109,14 @@ class TestPrebuiltTVShowPresets:
|
||||||
def test_compilation_errors_missing_one(
|
def test_compilation_errors_missing_one(
|
||||||
self,
|
self,
|
||||||
config,
|
config,
|
||||||
|
all_in_one_preset: Optional[str],
|
||||||
media_player_preset: str,
|
media_player_preset: str,
|
||||||
tv_show_structure_preset: str,
|
tv_show_structure_preset: str,
|
||||||
):
|
):
|
||||||
parent_presets: List[str] = [media_player_preset, tv_show_structure_preset]
|
parent_presets = _tv_show_by_date_parent_presets(
|
||||||
|
all_in_one_preset, media_player_preset, tv_show_structure_preset
|
||||||
|
)
|
||||||
|
|
||||||
for parent_preset in parent_presets:
|
for parent_preset in parent_presets:
|
||||||
parent_presets_missing_one = copy.deepcopy(parent_presets).remove(parent_preset)
|
parent_presets_missing_one = copy.deepcopy(parent_presets).remove(parent_preset)
|
||||||
|
|
||||||
|
|
@ -94,6 +142,7 @@ class TestPrebuiltTVShowPresets:
|
||||||
subscription_name,
|
subscription_name,
|
||||||
output_directory,
|
output_directory,
|
||||||
mock_download_collection_entries,
|
mock_download_collection_entries,
|
||||||
|
all_in_one_preset: Optional[str],
|
||||||
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,
|
||||||
|
|
@ -105,7 +154,9 @@ class TestPrebuiltTVShowPresets:
|
||||||
int(is_youtube_channel),
|
int(is_youtube_channel),
|
||||||
"_many_urls" if is_many_urls else "",
|
"_many_urls" if is_many_urls else "",
|
||||||
)
|
)
|
||||||
parent_presets = [media_player_preset, tv_show_structure_preset]
|
parent_presets = _tv_show_by_date_parent_presets(
|
||||||
|
all_in_one_preset, media_player_preset, tv_show_structure_preset
|
||||||
|
)
|
||||||
|
|
||||||
preset_dict = {
|
preset_dict = {
|
||||||
"preset": parent_presets,
|
"preset": parent_presets,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue