mass edit of tests
This commit is contained in:
parent
ed27c84853
commit
22c3d76217
14 changed files with 83 additions and 85 deletions
|
|
@ -178,7 +178,7 @@ class ConfigOptions(StrictDictValidator):
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
ytdl-sub dl --preset "music_video" --download.url "youtube.com/watch?v=a1b2c3"
|
ytdl-sub dl --preset "Jellyfin Music Videos" --download.url "youtube.com/watch?v=a1b2c3"
|
||||||
|
|
||||||
to
|
to
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ from ytdl_sub.utils.file_handler import FileHandler
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def music_video_config_for_cli(music_video_config) -> str:
|
def default_config_for_cli(default_config) -> str:
|
||||||
with tempfile.NamedTemporaryFile(suffix=".yaml", delete=False) as tmp_file:
|
with tempfile.NamedTemporaryFile(suffix=".yaml", delete=False) as tmp_file:
|
||||||
tmp_file.write(json.dumps(music_video_config._value).encode("utf-8"))
|
tmp_file.write(json.dumps(default_config._value).encode("utf-8"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
yield tmp_file.name
|
yield tmp_file.name
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sponsorblock_and_subs_preset_dict(output_directory) -> Dict:
|
def sponsorblock_and_subs_preset_dict(output_directory) -> Dict:
|
||||||
return {
|
return {
|
||||||
"preset": "music_video",
|
"preset": "Jellyfin Music Videos",
|
||||||
"download": "https://www.youtube.com/watch?v=-wJOUAuKZm8",
|
"download": "https://www.youtube.com/watch?v=-wJOUAuKZm8",
|
||||||
# override the output directory with our fixture-generated dir
|
# override the output directory with our fixture-generated dir
|
||||||
"output_options": {"output_directory": output_directory},
|
"output_options": {"output_directory": output_directory},
|
||||||
|
|
@ -57,13 +57,13 @@ class TestChapters:
|
||||||
@pytest.mark.parametrize("dry_run", [True, False])
|
@pytest.mark.parametrize("dry_run", [True, False])
|
||||||
def test_chapters_sponsorblock_and_removal_with_subs(
|
def test_chapters_sponsorblock_and_removal_with_subs(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
sponsorblock_and_subs_preset_dict,
|
sponsorblock_and_subs_preset_dict,
|
||||||
output_directory,
|
output_directory,
|
||||||
dry_run,
|
dry_run,
|
||||||
):
|
):
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="sponsorblock_with_embedded_subs_test",
|
preset_name="sponsorblock_with_embedded_subs_test",
|
||||||
preset_dict=sponsorblock_and_subs_preset_dict,
|
preset_dict=sponsorblock_and_subs_preset_dict,
|
||||||
)
|
)
|
||||||
|
|
@ -86,14 +86,14 @@ class TestChapters:
|
||||||
@pytest.mark.parametrize("dry_run", [True, False])
|
@pytest.mark.parametrize("dry_run", [True, False])
|
||||||
def test_chapters_from_comments(
|
def test_chapters_from_comments(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
chapters_from_comments_preset_dict,
|
chapters_from_comments_preset_dict,
|
||||||
timestamps_file_path,
|
timestamps_file_path,
|
||||||
output_directory,
|
output_directory,
|
||||||
dry_run,
|
dry_run,
|
||||||
):
|
):
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="chapters_from_comments",
|
preset_name="chapters_from_comments",
|
||||||
preset_dict=chapters_from_comments_preset_dict,
|
preset_dict=chapters_from_comments_preset_dict,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def preset_dict(output_directory):
|
def preset_dict(output_directory):
|
||||||
return {
|
return {
|
||||||
"preset": "music_video",
|
"preset": "Jellyfin Music Videos",
|
||||||
"download": "https://www.youtube.com/watch?v=2zYF9JLHDmA",
|
"download": "https://www.youtube.com/watch?v=2zYF9JLHDmA",
|
||||||
"output_options": {"output_directory": output_directory},
|
"output_options": {"output_directory": output_directory},
|
||||||
# download the worst format so it is fast
|
# download the worst format so it is fast
|
||||||
|
|
@ -24,13 +24,13 @@ class TestFileConvert:
|
||||||
@pytest.mark.parametrize("dry_run", [True, False])
|
@pytest.mark.parametrize("dry_run", [True, False])
|
||||||
def test_file_convert(
|
def test_file_convert(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
preset_dict,
|
preset_dict,
|
||||||
output_directory,
|
output_directory,
|
||||||
dry_run,
|
dry_run,
|
||||||
):
|
):
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="file_convert_test",
|
preset_name="file_convert_test",
|
||||||
preset_dict=preset_dict,
|
preset_dict=preset_dict,
|
||||||
)
|
)
|
||||||
|
|
@ -50,7 +50,7 @@ class TestFileConvert:
|
||||||
@pytest.mark.parametrize("dry_run", [True, False])
|
@pytest.mark.parametrize("dry_run", [True, False])
|
||||||
def test_file_convert_custom_ffmpeg(
|
def test_file_convert_custom_ffmpeg(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
preset_dict,
|
preset_dict,
|
||||||
output_directory,
|
output_directory,
|
||||||
dry_run,
|
dry_run,
|
||||||
|
|
@ -66,7 +66,7 @@ class TestFileConvert:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="file_convert_test",
|
preset_name="file_convert_test",
|
||||||
preset_dict=preset_dict,
|
preset_dict=preset_dict,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def preset_dict(output_directory):
|
def preset_dict(output_directory):
|
||||||
return {
|
return {
|
||||||
"preset": "music_video",
|
"preset": "Jellyfin Music Videos",
|
||||||
"download": "https://www.youtube.com/watch?v=2zYF9JLHDmA",
|
"download": "https://www.youtube.com/watch?v=2zYF9JLHDmA",
|
||||||
"output_options": {"output_directory": output_directory},
|
"output_options": {"output_directory": output_directory},
|
||||||
"ytdl_options": {
|
"ytdl_options": {
|
||||||
|
|
@ -21,7 +21,7 @@ def preset_dict(output_directory):
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def playlist_preset_dict(output_directory):
|
def playlist_preset_dict(output_directory):
|
||||||
return {
|
return {
|
||||||
"preset": "music_video",
|
"preset": "Jellyfin Music Videos",
|
||||||
"download": "https://www.youtube.com/playlist?list=PL5BC0FC26BECA5A35",
|
"download": "https://www.youtube.com/playlist?list=PL5BC0FC26BECA5A35",
|
||||||
"output_options": {"output_directory": output_directory},
|
"output_options": {"output_directory": output_directory},
|
||||||
"ytdl_options": {
|
"ytdl_options": {
|
||||||
|
|
@ -34,7 +34,7 @@ def playlist_preset_dict(output_directory):
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def livestream_preset_dict(output_directory):
|
def livestream_preset_dict(output_directory):
|
||||||
return {
|
return {
|
||||||
"preset": "music_video",
|
"preset": "Jellyfin Music Videos",
|
||||||
"download": "https://www.youtube.com/watch?v=DoUOrTJbIu4",
|
"download": "https://www.youtube.com/watch?v=DoUOrTJbIu4",
|
||||||
"output_options": {"output_directory": output_directory},
|
"output_options": {"output_directory": output_directory},
|
||||||
"ytdl_options": {
|
"ytdl_options": {
|
||||||
|
|
@ -46,12 +46,12 @@ def livestream_preset_dict(output_directory):
|
||||||
class TestFileConvert:
|
class TestFileConvert:
|
||||||
def test_livestreams_download_filtered(
|
def test_livestreams_download_filtered(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
livestream_preset_dict,
|
livestream_preset_dict,
|
||||||
output_directory,
|
output_directory,
|
||||||
):
|
):
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="match_filter_test",
|
preset_name="match_filter_test",
|
||||||
preset_dict=livestream_preset_dict,
|
preset_dict=livestream_preset_dict,
|
||||||
)
|
)
|
||||||
|
|
@ -62,13 +62,13 @@ class TestFileConvert:
|
||||||
@pytest.mark.parametrize("dry_run", [True, False])
|
@pytest.mark.parametrize("dry_run", [True, False])
|
||||||
def test_match_filters_empty(
|
def test_match_filters_empty(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
preset_dict,
|
preset_dict,
|
||||||
output_directory,
|
output_directory,
|
||||||
dry_run,
|
dry_run,
|
||||||
):
|
):
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="match_filter_test",
|
preset_name="match_filter_test",
|
||||||
preset_dict=preset_dict,
|
preset_dict=preset_dict,
|
||||||
)
|
)
|
||||||
|
|
@ -79,13 +79,13 @@ class TestFileConvert:
|
||||||
@pytest.mark.parametrize("dry_run", [True, False])
|
@pytest.mark.parametrize("dry_run", [True, False])
|
||||||
def test_match_filters_partial(
|
def test_match_filters_partial(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
playlist_preset_dict,
|
playlist_preset_dict,
|
||||||
output_directory,
|
output_directory,
|
||||||
dry_run,
|
dry_run,
|
||||||
):
|
):
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="match_filter_test",
|
preset_name="match_filter_test",
|
||||||
preset_dict=playlist_preset_dict,
|
preset_dict=playlist_preset_dict,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def subscription_dict(output_directory):
|
def subscription_dict(output_directory):
|
||||||
return {
|
return {
|
||||||
"preset": "music_video",
|
"preset": "Jellyfin Music Videos",
|
||||||
"download": "https://www.youtube.com/shorts/ucYmEqmlhFw",
|
"download": "https://www.youtube.com/shorts/ucYmEqmlhFw",
|
||||||
# override the output directory with our fixture-generated dir
|
# override the output directory with our fixture-generated dir
|
||||||
"output_options": {"output_directory": output_directory},
|
"output_options": {"output_directory": output_directory},
|
||||||
|
|
@ -59,7 +59,7 @@ def subscription_dict(output_directory):
|
||||||
|
|
||||||
class TestNfoTagsPlugins:
|
class TestNfoTagsPlugins:
|
||||||
@pytest.mark.parametrize("kodi_safe", [True, False])
|
@pytest.mark.parametrize("kodi_safe", [True, False])
|
||||||
def test_nfo_tags(self, subscription_dict, music_video_config, output_directory, kodi_safe):
|
def test_nfo_tags(self, subscription_dict, default_config, output_directory, kodi_safe):
|
||||||
transaction_log_file_name = "test_nfo.txt"
|
transaction_log_file_name = "test_nfo.txt"
|
||||||
if kodi_safe:
|
if kodi_safe:
|
||||||
transaction_log_file_name = "test_nfo_kodi_safe.txt"
|
transaction_log_file_name = "test_nfo_kodi_safe.txt"
|
||||||
|
|
@ -67,7 +67,7 @@ class TestNfoTagsPlugins:
|
||||||
subscription_dict["output_directory_nfo_tags"]["kodi_safe"] = True
|
subscription_dict["output_directory_nfo_tags"]["kodi_safe"] = True
|
||||||
|
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="kodi_safe_xml",
|
preset_name="kodi_safe_xml",
|
||||||
preset_dict=subscription_dict,
|
preset_dict=subscription_dict,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ from ytdl_sub.utils.exceptions import ValidationException
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def regex_subscription_dict_base(output_directory):
|
def regex_subscription_dict_base(output_directory):
|
||||||
return {
|
return {
|
||||||
"preset": "music_video",
|
"preset": "Jellyfin Music Videos",
|
||||||
"download": "https://youtube.com/playlist?list=PL5BC0FC26BECA5A35",
|
"download": "https://youtube.com/playlist?list=PL5BC0FC26BECA5A35",
|
||||||
# override the output directory with our fixture-generated dir
|
# override the output directory with our fixture-generated dir
|
||||||
"output_options": {"output_directory": output_directory},
|
"output_options": {"output_directory": output_directory},
|
||||||
|
|
@ -171,9 +171,9 @@ def regex_subscription_dict_match_and_exclude_override_variable(
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def playlist_subscription(music_video_config, regex_subscription_dict):
|
def playlist_subscription(default_config, regex_subscription_dict):
|
||||||
return Subscription.from_dict(
|
return Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="regex_capture_playlist_test",
|
preset_name="regex_capture_playlist_test",
|
||||||
preset_dict=regex_subscription_dict,
|
preset_dict=regex_subscription_dict,
|
||||||
)
|
)
|
||||||
|
|
@ -181,12 +181,12 @@ def playlist_subscription(music_video_config, regex_subscription_dict):
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def playlist_subscription_no_match_fails(
|
def playlist_subscription_no_match_fails(
|
||||||
music_video_config: ConfigFile, regex_subscription_dict: Dict[str, Any]
|
default_config: ConfigFile, regex_subscription_dict: Dict[str, Any]
|
||||||
):
|
):
|
||||||
regex_subscription_dict["regex"]["skip_if_match_fails"] = False
|
regex_subscription_dict["regex"]["skip_if_match_fails"] = False
|
||||||
|
|
||||||
return Subscription.from_dict(
|
return Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="regex_capture_playlist_test",
|
preset_name="regex_capture_playlist_test",
|
||||||
preset_dict=regex_subscription_dict,
|
preset_dict=regex_subscription_dict,
|
||||||
)
|
)
|
||||||
|
|
@ -194,10 +194,10 @@ def playlist_subscription_no_match_fails(
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def playlist_subscription_exclude(
|
def playlist_subscription_exclude(
|
||||||
music_video_config: ConfigFile, regex_subscription_dict_exclude: Dict[str, Any]
|
default_config: ConfigFile, regex_subscription_dict_exclude: Dict[str, Any]
|
||||||
) -> Subscription:
|
) -> Subscription:
|
||||||
return Subscription.from_dict(
|
return Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="regex_exclude_playlist_test",
|
preset_name="regex_exclude_playlist_test",
|
||||||
preset_dict=regex_subscription_dict_exclude,
|
preset_dict=regex_subscription_dict_exclude,
|
||||||
)
|
)
|
||||||
|
|
@ -205,11 +205,11 @@ def playlist_subscription_exclude(
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def playlist_subscription_overrides(
|
def playlist_subscription_overrides(
|
||||||
music_video_config: ConfigFile,
|
default_config: ConfigFile,
|
||||||
regex_subscription_dict_match_and_exclude_override_variable: Dict[str, Any],
|
regex_subscription_dict_match_and_exclude_override_variable: Dict[str, Any],
|
||||||
) -> Subscription:
|
) -> Subscription:
|
||||||
return Subscription.from_dict(
|
return Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="regex_using_overrides_test",
|
preset_name="regex_using_overrides_test",
|
||||||
preset_dict=regex_subscription_dict_match_and_exclude_override_variable,
|
preset_dict=regex_subscription_dict_match_and_exclude_override_variable,
|
||||||
)
|
)
|
||||||
|
|
@ -217,10 +217,10 @@ def playlist_subscription_overrides(
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def playlist_subscription_match_and_exclude(
|
def playlist_subscription_match_and_exclude(
|
||||||
music_video_config: ConfigFile, regex_subscription_dict_match_and_exclude: Dict[str, Any]
|
default_config: ConfigFile, regex_subscription_dict_match_and_exclude: Dict[str, Any]
|
||||||
) -> Subscription:
|
) -> Subscription:
|
||||||
return Subscription.from_dict(
|
return Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="regex_match_and_exclude_playlist_test",
|
preset_name="regex_match_and_exclude_playlist_test",
|
||||||
preset_dict=regex_subscription_dict_match_and_exclude,
|
preset_dict=regex_subscription_dict_match_and_exclude,
|
||||||
)
|
)
|
||||||
|
|
@ -275,7 +275,7 @@ class TestRegex:
|
||||||
_ = playlist_subscription_no_match_fails.download(dry_run=True)
|
_ = playlist_subscription_no_match_fails.download(dry_run=True)
|
||||||
|
|
||||||
def test_regex_fails_capture_group_with_only_excludes(
|
def test_regex_fails_capture_group_with_only_excludes(
|
||||||
self, regex_subscription_dict_exclude, music_video_config
|
self, regex_subscription_dict_exclude, default_config
|
||||||
):
|
):
|
||||||
regex_subscription_dict_exclude["regex"]["from"]["title"]["capture_group_names"] = ["uid"]
|
regex_subscription_dict_exclude["regex"]["from"]["title"]["capture_group_names"] = ["uid"]
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
|
|
@ -285,25 +285,25 @@ class TestRegex:
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
_ = Subscription.from_dict(
|
_ = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="test_regex_fails_capture_group_is_source_variable",
|
preset_name="test_regex_fails_capture_group_is_source_variable",
|
||||||
preset_dict=regex_subscription_dict_exclude,
|
preset_dict=regex_subscription_dict_exclude,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_regex_fails_no_match_or_exclude(self, regex_subscription_dict, music_video_config):
|
def test_regex_fails_no_match_or_exclude(self, regex_subscription_dict, default_config):
|
||||||
del regex_subscription_dict["regex"]["from"]["title"]["match"]
|
del regex_subscription_dict["regex"]["from"]["title"]["match"]
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
ValidationException,
|
ValidationException,
|
||||||
match=re.escape("must specify either `match` or `exclude`"),
|
match=re.escape("must specify either `match` or `exclude`"),
|
||||||
):
|
):
|
||||||
_ = Subscription.from_dict(
|
_ = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="test_regex_fails_capture_group_is_source_variable",
|
preset_name="test_regex_fails_capture_group_is_source_variable",
|
||||||
preset_dict=regex_subscription_dict,
|
preset_dict=regex_subscription_dict,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_regex_fails_capture_group_is_source_variable(
|
def test_regex_fails_capture_group_is_source_variable(
|
||||||
self, regex_subscription_dict, music_video_config
|
self, regex_subscription_dict, default_config
|
||||||
):
|
):
|
||||||
regex_subscription_dict["regex"]["from"]["title"]["capture_group_names"][0] = "uid"
|
regex_subscription_dict["regex"]["from"]["title"]["capture_group_names"][0] = "uid"
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
|
|
@ -313,13 +313,13 @@ class TestRegex:
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
_ = Subscription.from_dict(
|
_ = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="test_regex_fails_capture_group_is_source_variable",
|
preset_name="test_regex_fails_capture_group_is_source_variable",
|
||||||
preset_dict=regex_subscription_dict,
|
preset_dict=regex_subscription_dict,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_regex_fails_capture_group_is_override_variable(
|
def test_regex_fails_capture_group_is_override_variable(
|
||||||
self, regex_subscription_dict, music_video_config
|
self, regex_subscription_dict, default_config
|
||||||
):
|
):
|
||||||
regex_subscription_dict["regex"]["from"]["title"]["capture_group_names"][
|
regex_subscription_dict["regex"]["from"]["title"]["capture_group_names"][
|
||||||
0
|
0
|
||||||
|
|
@ -331,13 +331,13 @@ class TestRegex:
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
_ = Subscription.from_dict(
|
_ = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="test_regex_fails_capture_group_is_override_variable",
|
preset_name="test_regex_fails_capture_group_is_override_variable",
|
||||||
preset_dict=regex_subscription_dict,
|
preset_dict=regex_subscription_dict,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_regex_fails_source_variable_does_not_exist(
|
def test_regex_fails_source_variable_does_not_exist(
|
||||||
self, regex_subscription_dict, music_video_config
|
self, regex_subscription_dict, default_config
|
||||||
):
|
):
|
||||||
regex_subscription_dict["regex"]["from"]["dne"] = copy.deepcopy(
|
regex_subscription_dict["regex"]["from"]["dne"] = copy.deepcopy(
|
||||||
regex_subscription_dict["regex"]["from"]["title"]
|
regex_subscription_dict["regex"]["from"]["title"]
|
||||||
|
|
@ -349,26 +349,24 @@ class TestRegex:
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
_ = Subscription.from_dict(
|
_ = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="test_regex_fails_source_variable_does_not_exist",
|
preset_name="test_regex_fails_source_variable_does_not_exist",
|
||||||
preset_dict=regex_subscription_dict,
|
preset_dict=regex_subscription_dict,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_regex_fails_unequal_defaults(self, regex_subscription_dict, music_video_config):
|
def test_regex_fails_unequal_defaults(self, regex_subscription_dict, default_config):
|
||||||
regex_subscription_dict["regex"]["from"]["title"]["capture_group_defaults"] = ["1 != 2"]
|
regex_subscription_dict["regex"]["from"]["title"]["capture_group_defaults"] = ["1 != 2"]
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
ValidationException,
|
ValidationException,
|
||||||
match=re.escape("number of defaults must match number of capture groups, 1 != 2"),
|
match=re.escape("number of defaults must match number of capture groups, 1 != 2"),
|
||||||
):
|
):
|
||||||
_ = Subscription.from_dict(
|
_ = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="test_regex_fails_unequal_defaults",
|
preset_name="test_regex_fails_unequal_defaults",
|
||||||
preset_dict=regex_subscription_dict,
|
preset_dict=regex_subscription_dict,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_regex_fails_unequal_capture_group_names(
|
def test_regex_fails_unequal_capture_group_names(self, regex_subscription_dict, default_config):
|
||||||
self, regex_subscription_dict, music_video_config
|
|
||||||
):
|
|
||||||
regex_subscription_dict["regex"]["from"]["title"]["capture_group_names"].append("unequal")
|
regex_subscription_dict["regex"]["from"]["title"]["capture_group_names"].append("unequal")
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
ValidationException,
|
ValidationException,
|
||||||
|
|
@ -377,7 +375,7 @@ class TestRegex:
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
_ = Subscription.from_dict(
|
_ = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="test_regex_fails_unequal_capture_group_names",
|
preset_name="test_regex_fails_unequal_capture_group_names",
|
||||||
preset_dict=regex_subscription_dict,
|
preset_dict=regex_subscription_dict,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def single_video_subs_embed_preset_dict(output_directory):
|
def single_video_subs_embed_preset_dict(output_directory):
|
||||||
return {
|
return {
|
||||||
"preset": "music_video",
|
"preset": "Jellyfin Music Videos",
|
||||||
"download": "https://www.youtube.com/watch?v=2lAe1cqCOXo",
|
"download": "https://www.youtube.com/watch?v=2lAe1cqCOXo",
|
||||||
# override the output directory with our fixture-generated dir
|
# override the output directory with our fixture-generated dir
|
||||||
"output_options": {"output_directory": output_directory},
|
"output_options": {"output_directory": output_directory},
|
||||||
|
|
@ -32,9 +32,9 @@ def test_single_video_subs_embed_and_file_preset_dict(single_video_subs_embed_pr
|
||||||
|
|
||||||
|
|
||||||
class TestSubtitles:
|
class TestSubtitles:
|
||||||
def test_subtitle_lang_variable_partial_validates(self, music_video_config):
|
def test_subtitle_lang_variable_partial_validates(self, default_config):
|
||||||
music_video_config_dict = music_video_config.as_dict()
|
default_config_dict = default_config.as_dict()
|
||||||
music_video_config_dict["presets"]["music_video"]["subtitles"] = {
|
default_config_dict["presets"]["Jellyfin Music Videos"]["subtitles"] = {
|
||||||
"embed_subtitles": False,
|
"embed_subtitles": False,
|
||||||
"languages": ["en", "de"],
|
"languages": ["en", "de"],
|
||||||
"allow_auto_generated_subtitles": True,
|
"allow_auto_generated_subtitles": True,
|
||||||
|
|
@ -42,18 +42,18 @@ class TestSubtitles:
|
||||||
"subtitles_type": "srt",
|
"subtitles_type": "srt",
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = ConfigFile.from_dict(music_video_config_dict)
|
_ = ConfigFile.from_dict(default_config_dict)
|
||||||
|
|
||||||
@pytest.mark.parametrize("dry_run", [True, False])
|
@pytest.mark.parametrize("dry_run", [True, False])
|
||||||
def test_subtitles_embedded(
|
def test_subtitles_embedded(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
single_video_subs_embed_preset_dict,
|
single_video_subs_embed_preset_dict,
|
||||||
output_directory,
|
output_directory,
|
||||||
dry_run,
|
dry_run,
|
||||||
):
|
):
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="subtitles_embedded_test",
|
preset_name="subtitles_embedded_test",
|
||||||
preset_dict=single_video_subs_embed_preset_dict,
|
preset_dict=single_video_subs_embed_preset_dict,
|
||||||
)
|
)
|
||||||
|
|
@ -73,13 +73,13 @@ class TestSubtitles:
|
||||||
@pytest.mark.parametrize("dry_run", [True, False])
|
@pytest.mark.parametrize("dry_run", [True, False])
|
||||||
def test_subtitles_embedded_and_file(
|
def test_subtitles_embedded_and_file(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
test_single_video_subs_embed_and_file_preset_dict,
|
test_single_video_subs_embed_and_file_preset_dict,
|
||||||
output_directory,
|
output_directory,
|
||||||
dry_run,
|
dry_run,
|
||||||
):
|
):
|
||||||
subscription = Subscription.from_dict(
|
subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="subtitles_embedded_and_file_test",
|
preset_name="subtitles_embedded_and_file_test",
|
||||||
preset_dict=test_single_video_subs_embed_and_file_preset_dict,
|
preset_dict=test_single_video_subs_embed_and_file_preset_dict,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -103,13 +103,13 @@ class TestPlaylist:
|
||||||
@pytest.mark.parametrize("dry_run", [True, False])
|
@pytest.mark.parametrize("dry_run", [True, False])
|
||||||
def test_playlist_download(
|
def test_playlist_download(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
playlist_preset_dict,
|
playlist_preset_dict,
|
||||||
output_directory,
|
output_directory,
|
||||||
dry_run,
|
dry_run,
|
||||||
):
|
):
|
||||||
playlist_subscription = Subscription.from_dict(
|
playlist_subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="music_video_playlist_test",
|
preset_name="music_video_playlist_test",
|
||||||
preset_dict=playlist_preset_dict,
|
preset_dict=playlist_preset_dict,
|
||||||
)
|
)
|
||||||
|
|
@ -143,7 +143,7 @@ class TestPlaylist:
|
||||||
)
|
)
|
||||||
|
|
||||||
self._ensure_subscription_migrates(
|
self._ensure_subscription_migrates(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
subscription_name="music_video_playlist_test",
|
subscription_name="music_video_playlist_test",
|
||||||
subscription_dict=playlist_preset_dict,
|
subscription_dict=playlist_preset_dict,
|
||||||
output_directory=output_directory,
|
output_directory=output_directory,
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ from ytdl_sub.utils.thumbnail import try_convert_download_thumbnail
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def single_video_preset_dict_old_video_tags_format(output_directory):
|
def single_video_preset_dict_old_video_tags_format(output_directory):
|
||||||
return {
|
return {
|
||||||
"preset": "music_video",
|
"preset": "Jellyfin Music Videos",
|
||||||
"download": "https://youtube.com/watch?v=HKTNxEqsN3Q",
|
"download": "https://youtube.com/watch?v=HKTNxEqsN3Q",
|
||||||
# override the output directory with our fixture-generated dir
|
# override the output directory with our fixture-generated dir
|
||||||
"output_options": {
|
"output_options": {
|
||||||
|
|
@ -38,7 +38,7 @@ def single_video_preset_dict_old_video_tags_format(output_directory):
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def single_video_preset_dict(output_directory):
|
def single_video_preset_dict(output_directory):
|
||||||
return {
|
return {
|
||||||
"preset": "music_video",
|
"preset": "Jellyfin Music Videos",
|
||||||
"download": "https://youtube.com/watch?v=HKTNxEqsN3Q",
|
"download": "https://youtube.com/watch?v=HKTNxEqsN3Q",
|
||||||
# override the output directory with our fixture-generated dir
|
# override the output directory with our fixture-generated dir
|
||||||
"output_options": {
|
"output_options": {
|
||||||
|
|
@ -95,12 +95,12 @@ def single_video_preset_dict_dl_args(single_video_preset_dict):
|
||||||
class TestYoutubeVideo:
|
class TestYoutubeVideo:
|
||||||
def test_single_video_old_video_tags_format_download(
|
def test_single_video_old_video_tags_format_download(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
single_video_preset_dict_old_video_tags_format,
|
single_video_preset_dict_old_video_tags_format,
|
||||||
output_directory,
|
output_directory,
|
||||||
):
|
):
|
||||||
single_video_subscription = Subscription.from_dict(
|
single_video_subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="music_video_single_video_test",
|
preset_name="music_video_single_video_test",
|
||||||
preset_dict=single_video_preset_dict_old_video_tags_format,
|
preset_dict=single_video_preset_dict_old_video_tags_format,
|
||||||
)
|
)
|
||||||
|
|
@ -115,13 +115,13 @@ class TestYoutubeVideo:
|
||||||
@pytest.mark.parametrize("dry_run", [True])
|
@pytest.mark.parametrize("dry_run", [True])
|
||||||
def test_single_video_download(
|
def test_single_video_download(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
single_video_preset_dict,
|
single_video_preset_dict,
|
||||||
output_directory,
|
output_directory,
|
||||||
dry_run,
|
dry_run,
|
||||||
):
|
):
|
||||||
single_video_subscription = Subscription.from_dict(
|
single_video_subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="music_video_single_video_test",
|
preset_name="music_video_single_video_test",
|
||||||
preset_dict=single_video_preset_dict,
|
preset_dict=single_video_preset_dict,
|
||||||
)
|
)
|
||||||
|
|
@ -140,13 +140,13 @@ class TestYoutubeVideo:
|
||||||
|
|
||||||
def test_single_video_download_missing_thumbnail(
|
def test_single_video_download_missing_thumbnail(
|
||||||
self,
|
self,
|
||||||
music_video_config,
|
default_config,
|
||||||
single_video_preset_dict,
|
single_video_preset_dict,
|
||||||
working_directory,
|
working_directory,
|
||||||
output_directory,
|
output_directory,
|
||||||
):
|
):
|
||||||
single_video_subscription = Subscription.from_dict(
|
single_video_subscription = Subscription.from_dict(
|
||||||
config=music_video_config,
|
config=default_config,
|
||||||
preset_name="music_video_single_video_test",
|
preset_name="music_video_single_video_test",
|
||||||
preset_dict=single_video_preset_dict,
|
preset_dict=single_video_preset_dict,
|
||||||
)
|
)
|
||||||
|
|
@ -179,13 +179,13 @@ class TestYoutubeVideo:
|
||||||
@pytest.mark.parametrize("dry_run", [True, False])
|
@pytest.mark.parametrize("dry_run", [True, False])
|
||||||
def test_single_video_download_from_cli_dl(
|
def test_single_video_download_from_cli_dl(
|
||||||
self,
|
self,
|
||||||
music_video_config_path,
|
default_config_path,
|
||||||
single_video_preset_dict_dl_args,
|
single_video_preset_dict_dl_args,
|
||||||
output_directory,
|
output_directory,
|
||||||
dry_run,
|
dry_run,
|
||||||
):
|
):
|
||||||
args = "--dry-run " if dry_run else ""
|
args = "--dry-run " if dry_run else ""
|
||||||
args += f"--config {music_video_config_path} "
|
args += f"--config {default_config_path} "
|
||||||
args += f"dl {single_video_preset_dict_dl_args}"
|
args += f"dl {single_video_preset_dict_dl_args}"
|
||||||
subscriptions = mock_run_from_cli(args=args)
|
subscriptions = mock_run_from_cli(args=args)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,13 +65,13 @@ def persist_logs_directory() -> str:
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def persist_logs_config_factory(
|
def persist_logs_config_factory(
|
||||||
music_video_config: ConfigFile, persist_logs_directory: str
|
default_config: ConfigFile, persist_logs_directory: str
|
||||||
) -> Callable:
|
) -> Callable:
|
||||||
def _persist_logs_config_factory(keep_successful_logs: bool) -> ConfigFile:
|
def _persist_logs_config_factory(keep_successful_logs: bool) -> ConfigFile:
|
||||||
return ConfigFile.from_dict(
|
return ConfigFile.from_dict(
|
||||||
dict(
|
dict(
|
||||||
mergedeep.merge(
|
mergedeep.merge(
|
||||||
music_video_config.as_dict(),
|
default_config.as_dict(),
|
||||||
{
|
{
|
||||||
"configuration": {
|
"configuration": {
|
||||||
"persist_logs": {
|
"persist_logs": {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class TestDownloadArgsParser:
|
||||||
(
|
(
|
||||||
{"mv": "--preset music_video", "v": "--download.url"},
|
{"mv": "--preset music_video", "v": "--download.url"},
|
||||||
"dl --mv --v 123abc",
|
"dl --mv --v 123abc",
|
||||||
{"preset": "music_video", "download": {"url": "123abc"}},
|
{"preset": "Jellyfin Music Videos", "download": {"url": "123abc"}},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ def test_subscription_logs_write_to_file(
|
||||||
|
|
||||||
|
|
||||||
def test_update_with_info_json_requires_experimental_flag(
|
def test_update_with_info_json_requires_experimental_flag(
|
||||||
music_video_config_path: Path,
|
default_config_path: Path,
|
||||||
music_video_subscription_path: Path,
|
music_video_subscription_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
with patch.object(
|
with patch.object(
|
||||||
|
|
@ -90,7 +90,7 @@ def test_update_with_info_json_requires_experimental_flag(
|
||||||
[
|
[
|
||||||
"ytdl-sub",
|
"ytdl-sub",
|
||||||
"--config",
|
"--config",
|
||||||
str(music_video_config_path),
|
str(default_config_path),
|
||||||
"sub",
|
"sub",
|
||||||
str(music_video_subscription_path),
|
str(music_video_subscription_path),
|
||||||
"--update-with-info-json",
|
"--update-with-info-json",
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ def transaction_log_file_path() -> str:
|
||||||
@pytest.mark.parametrize("file_transaction_log", [None, "output.log"])
|
@pytest.mark.parametrize("file_transaction_log", [None, "output.log"])
|
||||||
def test_suppress_transaction_log(
|
def test_suppress_transaction_log(
|
||||||
mock_subscription_download_success,
|
mock_subscription_download_success,
|
||||||
music_video_config_path: Path,
|
default_config_path: Path,
|
||||||
music_video_subscription_path: Path,
|
music_video_subscription_path: Path,
|
||||||
file_transaction_log: Optional[str],
|
file_transaction_log: Optional[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -38,7 +38,7 @@ def test_suppress_transaction_log(
|
||||||
[
|
[
|
||||||
"ytdl-sub",
|
"ytdl-sub",
|
||||||
"--config",
|
"--config",
|
||||||
str(music_video_config_path),
|
str(default_config_path),
|
||||||
"sub",
|
"sub",
|
||||||
str(music_video_subscription_path),
|
str(music_video_subscription_path),
|
||||||
"--suppress-transaction-log",
|
"--suppress-transaction-log",
|
||||||
|
|
@ -53,7 +53,7 @@ def test_suppress_transaction_log(
|
||||||
|
|
||||||
def test_transaction_log_to_file(
|
def test_transaction_log_to_file(
|
||||||
mock_subscription_download_success,
|
mock_subscription_download_success,
|
||||||
music_video_config_path: Path,
|
default_config_path: Path,
|
||||||
music_video_subscription_path: Path,
|
music_video_subscription_path: Path,
|
||||||
transaction_log_file_path: Path,
|
transaction_log_file_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
@ -63,7 +63,7 @@ def test_transaction_log_to_file(
|
||||||
[
|
[
|
||||||
"ytdl-sub",
|
"ytdl-sub",
|
||||||
"--config",
|
"--config",
|
||||||
str(music_video_config_path),
|
str(default_config_path),
|
||||||
"sub",
|
"sub",
|
||||||
str(music_video_subscription_path),
|
str(music_video_subscription_path),
|
||||||
"--transaction-log",
|
"--transaction-log",
|
||||||
|
|
@ -79,7 +79,7 @@ def test_transaction_log_to_file(
|
||||||
|
|
||||||
def test_transaction_log_to_logger(
|
def test_transaction_log_to_logger(
|
||||||
mock_subscription_download_success,
|
mock_subscription_download_success,
|
||||||
music_video_config_path: Path,
|
default_config_path: Path,
|
||||||
music_video_subscription_path: Path,
|
music_video_subscription_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
with patch.object(
|
with patch.object(
|
||||||
|
|
@ -88,7 +88,7 @@ def test_transaction_log_to_logger(
|
||||||
[
|
[
|
||||||
"ytdl-sub",
|
"ytdl-sub",
|
||||||
"--config",
|
"--config",
|
||||||
str(music_video_config_path),
|
str(default_config_path),
|
||||||
"sub",
|
"sub",
|
||||||
str(music_video_subscription_path),
|
str(music_video_subscription_path),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue