compilation tests

This commit is contained in:
Jesse Bannon 2022-10-01 10:40:07 -07:00
parent 964530b162
commit 93fb3c1aa3
2 changed files with 137 additions and 37 deletions

View file

@ -28,7 +28,7 @@ presets:
season_number: "{collection_season_number}" season_number: "{collection_season_number}"
season_number_padded: "{collection_season_number_padded}" season_number_padded: "{collection_season_number_padded}"
tv_show_collection_season_1: collection_season_1:
generic: generic:
urls: urls:
- url: "{collection_season_1_url}" - url: "{collection_season_1_url}"
@ -52,7 +52,7 @@ presets:
attributes: attributes:
number: "1" number: "1"
tv_show_collection_season_2: collection_season_2:
generic: generic:
urls: urls:
- url: "{collection_season_2_url}" - url: "{collection_season_2_url}"
@ -70,7 +70,7 @@ presets:
attributes: attributes:
number: "2" number: "2"
tv_show_collection_season_3: collection_season_3:
generic: generic:
urls: urls:
- url: "{collection_season_3_url}" - url: "{collection_season_3_url}"
@ -88,7 +88,7 @@ presets:
attributes: attributes:
number: "3" number: "3"
tv_show_collection_season_4: collection_season_4:
generic: generic:
urls: urls:
- url: "{collection_season_4_url}" - url: "{collection_season_4_url}"
@ -106,7 +106,7 @@ presets:
attributes: attributes:
number: "4" number: "4"
tv_show_collection_season_5: collection_season_5:
generic: generic:
urls: urls:
- url: "{collection_season_5_url}" - url: "{collection_season_5_url}"

View file

@ -1,3 +1,4 @@
import copy
from typing import Dict from typing import Dict
from typing import List from typing import List
@ -9,25 +10,70 @@ from ytdl_sub.prebuilt_presets.tv_show import PrebuiltJellyfinTVShowPresets
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltKodiTVShowPresets from ytdl_sub.prebuilt_presets.tv_show import PrebuiltKodiTVShowPresets
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltPlexTVShowPresets from ytdl_sub.prebuilt_presets.tv_show import PrebuiltPlexTVShowPresets
from ytdl_sub.subscriptions.subscription import Subscription from ytdl_sub.subscriptions.subscription import Subscription
from ytdl_sub.utils.exceptions import ValidationException
class TestPrebuiltTVShowPresets: @pytest.mark.parametrize(
@pytest.mark.parametrize(
"media_player_preset", "media_player_preset",
[ [
"kodi_tv_show_url", "kodi_tv_show_url",
"jellyfin_tv_show_url", "jellyfin_tv_show_url",
"plex_tv_show_url", "plex_tv_show_url",
], ],
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
"tv_show_structure_preset", "tv_show_structure_preset",
[ [
"season_by_year__episode_by_month_day", "season_by_year__episode_by_month_day",
"season_by_year__episode_by_month_day_reversed", "season_by_year__episode_by_month_day_reversed",
"season_by_year_month__episode_by_day", "season_by_year_month__episode_by_day",
], ],
)
class TestPrebuiltTVShowPresets:
def test_compilation(
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,
"overrides": {
"url": "https://your.name.here",
"tv_show_name": "test-compile",
"tv_show_directory": "output_dir",
},
},
) )
def test_compilation_errors_missing_one(
self,
config,
media_player_preset: str,
tv_show_structure_preset: str,
):
parent_presets: List[str] = [media_player_preset, tv_show_structure_preset]
for parent_preset in parent_presets:
parent_presets_missing_one = copy.deepcopy(parent_presets).remove(parent_preset)
with pytest.raises(ValidationException):
_ = Subscription.from_dict(
config=config,
preset_name="preset_test",
preset_dict={
"preset": parent_presets_missing_one,
"overrides": {
"url": "https://your.name.here",
"tv_show_name": "test-compile",
"tv_show_directory": "output_dir",
},
},
)
@pytest.mark.parametrize("is_youtube_channel", [True, False]) @pytest.mark.parametrize("is_youtube_channel", [True, False])
def test_non_collection_presets_compile( def test_non_collection_presets_compile(
self, self,
@ -75,21 +121,75 @@ class TestPrebuiltTVShowPresets:
regenerate_expected_download_summary=True, regenerate_expected_download_summary=True,
) )
@pytest.mark.parametrize(
@pytest.mark.parametrize(
"media_player_preset", "media_player_preset",
[ [
"kodi_tv_show_collection", "kodi_tv_show_collection",
"jellyfin_tv_show_collection", "jellyfin_tv_show_collection",
"plex_tv_show_collection", "plex_tv_show_collection",
], ],
) )
@pytest.mark.parametrize( @pytest.mark.parametrize(
"tv_show_structure_preset", "tv_show_structure_preset",
[ [
"season_by_collection__episode_by_year_month_day", "season_by_collection__episode_by_year_month_day",
"season_by_collection__episode_by_year_month_day_reversed", "season_by_collection__episode_by_year_month_day_reversed",
], ],
)
class TestPrebuiltTvShowCollectionPresets:
@pytest.mark.parametrize("season_preset", ["collection_season_1", "collection_season_2"])
def test_compilation(
self,
config,
media_player_preset: str,
tv_show_structure_preset: str,
season_preset: str,
):
parent_presets: List[str] = [media_player_preset, tv_show_structure_preset, season_preset]
_ = Subscription.from_dict(
config=config,
preset_name="preset_test",
preset_dict={
"preset": parent_presets,
"overrides": {
"url": "https://your.name.here",
"tv_show_name": "test-compile",
"tv_show_directory": "output_dir",
f"{season_preset}_url": "https://your.name.here",
f"{season_preset}_name": "test season name",
},
},
) )
@pytest.mark.parametrize("season_preset", ["collection_season_1", "collection_season_2"])
def test_compilation_errors_missing_one(
self,
config,
media_player_preset: str,
tv_show_structure_preset: str,
season_preset: str,
):
parent_presets: List[str] = [media_player_preset, tv_show_structure_preset, season_preset]
for parent_preset in parent_presets:
parent_presets_missing_one = copy.deepcopy(parent_presets).remove(parent_preset)
with pytest.raises(ValidationException):
_ = Subscription.from_dict(
config=config,
preset_name="preset_test",
preset_dict={
"preset": parent_presets_missing_one,
"overrides": {
"url": "https://your.name.here",
"tv_show_name": "test-compile",
"tv_show_directory": "output_dir",
f"{season_preset}_url": "https://your.name.here",
f"{season_preset}_name": "test season name",
},
},
)
@pytest.mark.parametrize("season_indices", [[1], [1, 2]]) @pytest.mark.parametrize("season_indices", [[1], [1, 2]])
@pytest.mark.parametrize("is_youtube_channel", [True, False]) @pytest.mark.parametrize("is_youtube_channel", [True, False])
def test_collection_presets_compile( def test_collection_presets_compile(
@ -113,7 +213,7 @@ class TestPrebuiltTVShowPresets:
overrides: Dict[str, str] = {} overrides: Dict[str, str] = {}
for season_index in season_indices: for season_index in season_indices:
parent_presets.append(f"tv_show_collection_season_{season_index}") parent_presets.append(f"collection_season_{season_index}")
overrides = dict( overrides = dict(
overrides, overrides,