test: delete slow, timing-based and redundant tests

This commit is contained in:
imSp4rky
2026-12-05 15:20:05 -07:00
parent 783a2fc185
commit 3a0a74e694
292 changed files with 153 additions and 15174 deletions
-34
View File
@@ -3,19 +3,14 @@
from __future__ import annotations
import struct
import subprocess
from pathlib import Path
from uuid import UUID
import pytest
from tests.core.test_ffmpeg_decodes import GOP, video
from tests.core.test_kid_windows import box, full
from unshackle.core import binaries
from unshackle.core.config import config
from unshackle.core.drm import ClearKeyCENC
from unshackle.core.drm.verify import decrypter_for, offsets_not_moof_relative
from unshackle.core.utils.subprocess import ffmpeg_decodes
KID = UUID("11223344556677889900aabbccddeeff")
KEY = "00112233445566778899aabbccddeeff"
@@ -63,38 +58,9 @@ def test_offsets_not_moof_relative(tmp_path: Path, data: bytes, expected: bool)
assert offsets_not_moof_relative(path) is expected
def test_a_missing_file_is_not_detected(tmp_path: Path) -> None:
assert offsets_not_moof_relative(tmp_path / "gone.mp4") is False
def test_decrypter_for_routes_only_the_shaka_default(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
(flagged := tmp_path / "gpac.mp4").write_bytes(box(b"moov") + fragment(trun(0xA04), tfhd=ABSOLUTE))
(normal := tmp_path / "dash.mp4").write_bytes(box(b"moov") + fragment(trun(0xA05)))
monkeypatch.setattr(config, "decryption", "shaka")
assert decrypter_for(flagged) == "mp4decrypt"
assert decrypter_for(normal) == "shaka"
@pytest.mark.skipif(
not (binaries.FFMPEG and binaries.MP4Box and binaries.Mp4decrypt and binaries.ShakaPackager),
reason="needs FFmpeg, MP4Box, mp4decrypt and shaka-packager",
)
def test_a_gpac_fragmented_track_decrypts_under_the_shaka_default(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
def run(*cmd: object) -> None:
subprocess.run([str(part) for part in cmd], cwd=tmp_path, check=True, capture_output=True)
video(tmp_path / "src.mp4", *GOP, size="640x360")
(tmp_path / "drm.xml").write_text(GPAC_DRM)
run(binaries.MP4Box, "-quiet", "-crypt", "drm.xml", "src.mp4", "-out", "enc.mp4")
run(binaries.MP4Box, "-quiet", "-frag", "2000", "enc.mp4", "-out", "track.mp4")
track = tmp_path / "track.mp4"
monkeypatch.setattr(config, "decryption", "shaka")
monkeypatch.setattr(config.directories, "temp", tmp_path / "temp")
picked = decrypter_for(track)
ClearKeyCENC(kids=[KID], content_keys={KID: KEY}).decrypt(track)
assert ffmpeg_decodes(track, video=True)
assert picked == "mp4decrypt"