This commit is contained in:
Jesse Bannon 2023-12-27 10:31:02 -08:00
parent d22d19921a
commit 896a83938b
2 changed files with 2 additions and 20 deletions

View file

@ -72,9 +72,7 @@ class Subscription(SubscriptionDownload):
cls, config: ConfigFile, subscription_path: str | Path cls, config: ConfigFile, subscription_path: str | Path
) -> List["Subscription"]: ) -> List["Subscription"]:
""" """
Loads subscriptions from a file and applies ``__preset__`` to all of them if present. Loads subscriptions from a file.
If a subscription is in the form of key: value, it will set value to the override
variable defined in ``__value__``.
Parameters Parameters
---------- ----------

View file

@ -57,17 +57,6 @@ def preset_with_subscription_value(preset_with_file_preset: Dict):
) )
@pytest.fixture
def preset_with_subscription_file_value(preset_with_subscription_value: Dict):
return dict(
preset_with_subscription_value,
**{
"__value__": "test_file_subscription_value",
"test_value": "is_overwritten",
},
)
@pytest.fixture @pytest.fixture
def preset_with_subscription_value_nested_presets(preset_with_subscription_value: Dict): def preset_with_subscription_value_nested_presets(preset_with_subscription_value: Dict):
return dict( return dict(
@ -236,7 +225,6 @@ def test_subscription_overrides_tilda(
subs = Subscription.from_file_path(config=config_file, subscription_path="mocked") subs = Subscription.from_file_path(config=config_file, subscription_path="mocked")
assert len(subs) == 3 assert len(subs) == 3
# Test __value__ worked correctly from the config
sub_2_1 = [sub for sub in subs if sub.name == "test_2_1"][0].overrides.dict_with_format_strings sub_2_1 = [sub for sub in subs if sub.name == "test_2_1"][0].overrides.dict_with_format_strings
assert sub_2_1.get("subscription_name") == "test_2_1" assert sub_2_1.get("subscription_name") == "test_2_1"
@ -253,7 +241,6 @@ def test_subscription_file_value_applies_from_config_and_nested_and_indent_varia
subs = Subscription.from_file_path(config=config_file, subscription_path="mocked") subs = Subscription.from_file_path(config=config_file, subscription_path="mocked")
assert len(subs) == 4 assert len(subs) == 4
# Test __value__ worked correctly from the config
sub_test_value = [sub for sub in subs if sub.name == "test_value"][ sub_test_value = [sub for sub in subs if sub.name == "test_value"][
0 0
].overrides.dict_with_format_strings ].overrides.dict_with_format_strings
@ -293,7 +280,6 @@ def test_subscription_file_value_applies_from_config_and_nested_and_indent_varia
subs = Subscription.from_file_path(config=config_file, subscription_path="mocked") subs = Subscription.from_file_path(config=config_file, subscription_path="mocked")
assert len(subs) == 4 assert len(subs) == 4
# Test __value__ worked correctly from the config
sub_test_value = [sub for sub in subs if sub.name == "test_value"][ sub_test_value = [sub for sub in subs if sub.name == "test_value"][
0 0
].overrides.dict_with_format_strings ].overrides.dict_with_format_strings
@ -337,9 +323,7 @@ def test_subscription_file_value_applies_from_config_and_nested_and_indent_varia
def test_subscription_file_using_conflicting_preset_name(config_file: ConfigFile): def test_subscription_file_using_conflicting_preset_name(config_file: ConfigFile):
with mock_load_yaml( with mock_load_yaml(
preset_dict={ preset_dict={
"= INDENTS_IN_ERR_MSG ": { "= INDENTS_IN_ERR_MSG ": {"=ANOTHER": {"jellyfin_tv_show_by_date": "single value"}}
"=ANOTHER": {"jellyfin_tv_show_by_date": "single value, __value__ not defined"}
}
} }
), pytest.raises( ), pytest.raises(
ValidationException, ValidationException,