mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-10-29 18:22:22 +01:00
One service needed session_id in its license call, which a near-duplicate of get_content_keys supplied behind a service-tag test. service_licence now passes each service only the arguments its own license function declares, so the duplicate and the branch are gone. The REST API license paths and the base PlayReady delegate get the same filtering, replacing their fixed argument set. Two behaviour changes ride along: an empty license challenge now raises EmptyLicense for every service, not just the one, and a service that declares only challenge now receives a working call instead of a TypeError.
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from unshackle.core.utilities import declared_kwargs
|
|
|
|
SENT = {"challenge": b"c", "title": "t", "track": "tr", "pssh": "P", "session_id": "S"}
|
|
|
|
|
|
def test_keeps_only_declared_arguments() -> None:
|
|
def licence(*, challenge: bytes, title: str, track: str) -> None: ...
|
|
|
|
assert sorted(declared_kwargs(licence, SENT)) == ["challenge", "title", "track"]
|
|
|
|
|
|
def test_passes_session_id_to_a_function_that_asks_for_it() -> None:
|
|
def licence(*, challenge: bytes, title: str, track: str, session_id: str | None = None) -> None: ...
|
|
|
|
assert sorted(declared_kwargs(licence, SENT)) == ["challenge", "session_id", "title", "track"]
|
|
|
|
|
|
def test_a_var_keyword_function_gets_everything() -> None:
|
|
def licence(*, challenge: bytes, **kwargs: object) -> None: ...
|
|
|
|
assert declared_kwargs(licence, SENT) == SENT
|
|
|
|
|
|
def test_an_unreadable_signature_gets_everything() -> None:
|
|
# min() has no readable signature, and a compiled service may not either
|
|
assert declared_kwargs(min, SENT) == SENT
|
|
|
|
|
|
def test_a_signature_we_cannot_call_by_keyword_gets_everything() -> None:
|
|
def licence(challenge, /, **kwargs: object) -> None: ...
|
|
|
|
assert declared_kwargs(licence, SENT) == SENT
|