ytdl-sub/tests/unit/prebuilt_presets/test_tv_show_by_date.py
Jesse Bannon c163f9766a
[BACKEND] Configurable resolution level when validating variables (#1415)
Expands variable validation to also include support for partial resolution.

In short, this will partially execute script code until it hits unresolved runtime variables, and store that as the new script representation. This functionality will allow for the upcoming `inspect` command, which will show users their script code in action without having to dry-run.
2026-02-02 09:50:52 -08:00

92 lines
3.1 KiB
Python

import re
import pytest
import yaml
from ytdl_sub.script.utils.exceptions import UserThrownRuntimeError
from ytdl_sub.subscriptions.subscription import Subscription
class TestTvShowByDatePreset:
def test_s01_error_thrown(self, default_config):
with pytest.raises(
UserThrownRuntimeError,
match=re.escape(
"Provided `s01_url` or `s01_name` variable to TV Show by Date preset when it "
"expects `url`. Perhaps you meant to use the `TV Show Collection` preset?"
),
):
_ = Subscription.from_dict(
config=default_config,
preset_name="test",
preset_dict={
"preset": "Jellyfin TV Show by Date",
"overrides": {"tv_show_directory": "abc", "s01_url": "test"},
},
)
def test_backward_compatibility_single_download(self, default_config):
a = yaml.safe_load(
Subscription.from_dict(
config=default_config,
preset_name="a",
preset_dict={
"preset": "Jellyfin TV Show by Date",
"overrides": {"tv_show_directory": "abc", "url": "test_1"},
},
).resolved_yaml()
)
b = yaml.safe_load(
Subscription.from_dict(
config=default_config,
preset_name="a",
preset_dict={
"preset": "Jellyfin TV Show by Date",
"overrides": {"tv_show_directory": "abc", "subscription_value": "test_1"},
},
).resolved_yaml()
)
assert a["download"] == b["download"]
def test_backward_compatibility_multi_download(self, default_config):
a = yaml.safe_load(
Subscription.from_dict(
config=default_config,
preset_name="a",
preset_dict={
"preset": "Jellyfin TV Show by Date",
"overrides": {"tv_show_directory": "abc", "url": "test_1", "url2": "test_2"},
},
).resolved_yaml()
)
b = yaml.safe_load(
Subscription.from_dict(
config=default_config,
preset_name="a",
preset_dict={
"preset": "Jellyfin TV Show by Date",
"overrides": {
"tv_show_directory": "abc",
"subscription_array": ["test_1", "test_2"],
},
},
).resolved_yaml()
)
c = yaml.safe_load(
Subscription.from_dict(
config=default_config,
preset_name="a",
preset_dict={
"preset": "Jellyfin TV Show by Date",
"overrides": {"tv_show_directory": "abc", "urls": ["test_1", "test_2"]},
},
).resolved_yaml()
)
assert a["download"] == b["download"]
assert a["download"] == c["download"]