forked from kenzuya/unshackle
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -16,9 +16,6 @@ from pywidevine.pssh import PSSH
|
||||
|
||||
from tests.admission import refusal
|
||||
from tests.core.key_resolver import MemoryVault, key_table, resolver, vaults_of
|
||||
from unshackle.commands.dl import dl
|
||||
from unshackle.core.api.handlers import load_full_cdm, resolve_server_cdm
|
||||
from unshackle.core.cdm.detect import is_widevine_cdm
|
||||
from unshackle.core.drm import PlayReady, Widevine
|
||||
from unshackle.core.manifests import HLS
|
||||
|
||||
@@ -169,22 +166,6 @@ def test_a_playready_track_with_two_widevine_objects_licenses() -> None:
|
||||
assert run.requests == ["PlayReady", "Widevine"]
|
||||
|
||||
|
||||
def test_cdm_only_licenses_each_drm_system_and_does_not_read_the_vault() -> None:
|
||||
run = Run(vault={KID: VAULT_KEY}, cdm_only=True)
|
||||
wv, pr = run.drm(widevine()), run.drm(playready())
|
||||
|
||||
run.run(wv, pr)
|
||||
|
||||
assert run.requests == ["Widevine", "PlayReady"]
|
||||
assert run.vault_queries == []
|
||||
assert wv.content_keys == {KID: KEY} and pr.content_keys == {KID: KEY}
|
||||
assert is_widevine_cdm(run.keys.cdms.cdm)
|
||||
|
||||
run.run(run.drm(widevine()), run.drm(playready()))
|
||||
|
||||
assert run.requests == ["Widevine", "PlayReady"]
|
||||
|
||||
|
||||
def test_the_other_drm_system_can_return_a_different_set_of_kids() -> None:
|
||||
run = Run()
|
||||
wv = run.drm(widevine())
|
||||
@@ -219,22 +200,6 @@ def test_the_other_drm_system_licenses_only_for_a_kid_with_no_content_key() -> N
|
||||
assert run.requests == ["Widevine"]
|
||||
|
||||
|
||||
def test_the_init_segment_adds_the_drm_system_the_track_does_not_have(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
from unshackle.core.tracks import Track
|
||||
|
||||
wv, pr = widevine(), playready()
|
||||
monkeypatch.setattr(PlayReady, "from_init_data", classmethod(lambda cls, data: pr))
|
||||
monkeypatch.setattr(
|
||||
Widevine, "from_init_data", classmethod(lambda cls, data: pytest.fail("the track has Widevine already"))
|
||||
)
|
||||
track = SimpleNamespace(drm=[wv], prefers_playready=lambda cdm: True)
|
||||
track.pssh_order = lambda cdm: Track.pssh_order(track, cdm)
|
||||
|
||||
Track.add_init_drm(track, b"init", None)
|
||||
|
||||
assert track.drm == [wv, pr]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("preference", "found", "read", "expected"),
|
||||
[
|
||||
@@ -265,61 +230,3 @@ def test_drm_from_pssh_reads_the_preferred_system_first(
|
||||
assert tried == read
|
||||
assert track.drm == [expected]
|
||||
assert not caplog.records
|
||||
|
||||
|
||||
def test_drm_from_pssh_without_a_pssh_logs_once_and_keeps_the_drm(caplog: pytest.LogCaptureFixture) -> None:
|
||||
from unshackle.core.tracks import Video
|
||||
|
||||
track = Video("https://cdn.example/v.mp4", language="en")
|
||||
track.drm_preference = "pr"
|
||||
|
||||
def read_pssh(system: Any) -> Any:
|
||||
raise system.Exceptions.PSSHNotFound()
|
||||
|
||||
with caplog.at_level(logging.DEBUG, logger="EXAMPLE"):
|
||||
track.drm_from_pssh(None, read_pssh, logging.getLogger("EXAMPLE"))
|
||||
|
||||
assert track.drm is None
|
||||
assert [r.getMessage() for r in caplog.records] == [
|
||||
"No PlayReady or Widevine PSSH was found for this track, is it DRM free?"
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entry", "expected"),
|
||||
[
|
||||
({"playready": "pr_device", "widevine": "wv_device"}, "pr_device"),
|
||||
({"widevine": "wv_device", "playready": "pr_device"}, "wv_device"),
|
||||
],
|
||||
)
|
||||
def test_the_first_drm_system_of_the_config_entry_loads_first(
|
||||
monkeypatch: pytest.MonkeyPatch, entry: dict, expected: str
|
||||
) -> None:
|
||||
monkeypatch.setattr("unshackle.commands.dl.config.cdm", {"EXAMPLE": entry})
|
||||
monkeypatch.setattr("unshackle.core.cdm.load_cdm", lambda name, **_: name)
|
||||
monkeypatch.setattr("unshackle.core.config.config.cdm", {"EXAMPLE": entry})
|
||||
cmd = dl.__new__(dl)
|
||||
cmd.vaults = None
|
||||
|
||||
assert cmd.get_cdm("EXAMPLE") == expected
|
||||
assert load_full_cdm("EXAMPLE", None) == expected
|
||||
assert cmd.get_cdm("EXAMPLE", drm="widevine") == "wv_device"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("entry", "expected"),
|
||||
[
|
||||
({"playready": "pr_device", "widevine": "wv_device"}, "playready"),
|
||||
({"widevine": "wv_device", "playready": "pr_device"}, "widevine"),
|
||||
],
|
||||
)
|
||||
def test_the_server_cdm_stub_is_the_first_drm_system_of_the_config_entry(
|
||||
monkeypatch: pytest.MonkeyPatch, entry: dict, expected: str
|
||||
) -> None:
|
||||
monkeypatch.setattr("unshackle.core.config.config.cdm", {"EXAMPLE": entry})
|
||||
monkeypatch.setattr(
|
||||
"unshackle.core.api.handlers.device_system",
|
||||
lambda name, _: "playready" if name == "pr_device" else "widevine",
|
||||
)
|
||||
|
||||
assert is_widevine_cdm(resolve_server_cdm("EXAMPLE", None, None)) is (expected == "widevine")
|
||||
|
||||
Reference in New Issue
Block a user