forked from kenzuya/unshackle
refactor(api): give every served service its dl options from the run plan
This commit is contained in:
@@ -178,7 +178,7 @@ def test_nested_dl_params_reach_the_parent_ctx(monkeypatch):
|
||||
"v_lang": ["ja"],
|
||||
"a_lang": ["es-419"],
|
||||
"s_lang": ["ko"],
|
||||
"acodec": ["EC3", "NOPE", "AAC"],
|
||||
"acodec": ["EC3", "AAC"],
|
||||
"forced_subs": True,
|
||||
"exact_lang": True,
|
||||
}
|
||||
@@ -211,20 +211,21 @@ def test_a_service_lang_option_never_gets_the_dl_lang(monkeypatch):
|
||||
assert "dl_params" in handlers.SESSION_TRANSPORT_KEYS
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"dl_params",
|
||||
[
|
||||
"en",
|
||||
{"lang": "en", "v_lang": "ja", "a_lang": {"x": 1}, "acodec": "EC3", "forced_subs": "yes", "exact_lang": "yes"},
|
||||
{"lang": [1], "v_lang": [None], "a_lang": ["en", None], "acodec": [3], "forced_subs": 1, "exact_lang": 1},
|
||||
],
|
||||
)
|
||||
def test_malformed_dl_params_are_ignored(monkeypatch, dl_params):
|
||||
svc = _create_with_real_ctx(monkeypatch, {"dl_params": dl_params})
|
||||
def test_dl_params_that_are_not_an_object_are_ignored(monkeypatch):
|
||||
svc = _create_with_real_ctx(monkeypatch, {"dl_params": "en"})
|
||||
selection = {k: svc.parent_params[k] for k in (*DL_DEFAULTS,)}
|
||||
assert selection == DL_DEFAULTS
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"dl_params", [{"a_lang": {"x": 1}}, {"acodec": ["EC3", "NOPE"]}, {"acodec": [3]}, {"forced_subs": "maybe"}]
|
||||
)
|
||||
def test_a_malformed_dl_param_is_refused(monkeypatch, dl_params):
|
||||
with pytest.raises(handlers.APIError) as exc:
|
||||
_create_with_real_ctx(monkeypatch, {"dl_params": dl_params})
|
||||
assert exc.value.error_code is handlers.APIErrorCode.INVALID_PARAMETERS
|
||||
|
||||
|
||||
def test_profile_reaches_the_parent_ctx_params(monkeypatch):
|
||||
monkeypatch.setattr(key_policy, "load_service_config", lambda s: {})
|
||||
monkeypatch.setattr(handlers, "load_full_cdm", lambda *a: None)
|
||||
|
||||
Reference in New Issue
Block a user