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
-63
View File
@@ -2,8 +2,6 @@ from __future__ import annotations
import io
import itertools
import logging
import subprocess
from pathlib import Path
from types import SimpleNamespace
from typing import Any
@@ -11,7 +9,6 @@ from typing import Any
import pytest
from langcodes import Language
from unshackle.commands.dl import dl
from unshackle.core import binaries
from unshackle.core.config import config
from unshackle.core.drm.verify import decrypter_for
@@ -104,13 +101,6 @@ def test_a_track_with_a_second_video_layer_decrypts_with_mp4decrypt(
assert decrypter_for(flat) == "mp4decrypt"
def test_a_3d_title_muxes_with_mp4box(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
calls: list[str] = []
monkeypatch.setattr(Tracks, "_mux_mp4", lambda self, **kwargs: calls.append(kwargs["title"]) or (Path("x"), 0, []))
assert Tracks(stereo_video(tmp_path)).mux("Film")[1] == 0
assert calls == ["Film"]
@pytest.fixture
def mp4box_commands(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> list[list[str]]:
commands: list[list[str]] = []
@@ -147,14 +137,6 @@ def test_a_3d_mp4_mux_keeps_the_sample_whole(
assert "-for-test" in mp4box_commands[0]
def test_a_2d_mp4_sample_cut_keeps_no_date(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, mp4box_commands: list[list[str]]
) -> None:
monkeypatch.setattr(config, "sample", (120.0, 180.0))
Tracks(stereo_video(tmp_path, stereo=False))._mux_mp4(title="Film", output_path=tmp_path / "out.mkv")
assert mp4box_commands[1][1:3] == ["-for-test", "-splitx"]
def test_a_3d_mp4_mux_writes_quicktime_chapters(tmp_path: Path, mp4box_commands: list[list[str]]) -> None:
for stereo, flag in ((True, "-chapqt"), (False, "-chap")):
tracks = Tracks(stereo_video(tmp_path, stereo=stereo))
@@ -163,12 +145,6 @@ def test_a_3d_mp4_mux_writes_quicktime_chapters(tmp_path: Path, mp4box_commands:
assert flag in mp4box_commands[-1] and ({"-chap", "-chapqt"} - {flag}).isdisjoint(mp4box_commands[-1])
def test_a_3d_track_is_never_a_hybrid_ingredient(tmp_path: Path) -> None:
flat, layered = (stereo_video(tmp_path, stereo=s, range_=Video.Range.DV) for s in (False, True))
candidates, standalone = Tracks.partition_hybrid_videos([flat, layered], [])
assert candidates == [flat] and standalone == []
def test_2d_ranks_over_3d_at_one_resolution_and_the_signatures_differ(tmp_path: Path) -> None:
flat = stereo_video(tmp_path, stereo=False, height=1080, bitrate=5_000_000)
layered = stereo_video(tmp_path, stereo=True, height=1080, bitrate=9_000_000)
@@ -215,19 +191,6 @@ def test_the_filename_context_marks_a_3d_title(monkeypatch: pytest.MonkeyPatch)
assert (context(True), context(False)) == ("3D", "")
def test_worst_prefers_the_2d_track_at_one_height(tmp_path: Path) -> None:
videos = [
stereo_video(tmp_path, stereo=s, height=2160, bitrate=b)
for s, b in ((False, 9_000_000), (False, 5_000_000), (True, 40_000_000), (True, 30_000_000))
]
ranked = Tracks(videos)
ranked.sort_videos()
assert pick_video(ranked.videos, worst=True) is videos[1]
assert pick_video(ranked.videos, worst=False) is videos[0]
assert pick_video([videos[2], videos[3]], worst=True) is videos[3]
assert pick_video([], worst=True) is None
def test_worst_ranks_unknown_bitrates_and_sizes_highest(tmp_path: Path) -> None:
def ranked(*specs: tuple[bool, int, Any]) -> list[Video]:
tracks = Tracks([stereo_video(tmp_path, stereo=s, width=h * 16 // 9, height=h, bitrate=b) for s, h, b in specs])
@@ -275,17 +238,6 @@ def test_hybrid_never_pairs_a_3d_dv_track(tmp_path: Path) -> None:
assert hybrid_plan([base, layered], generate_dv=False) == ([], None)
def test_mp4_names_skip_the_extra_tracks_of_a_3d_video_file(tmp_path: Path, mp4box_commands: list[list[str]]) -> None:
video = stereo_video(tmp_path)
video.path.write_bytes(box(b"moov", box(b"trak") + box(b"trak")))
audio = Audio(url="https://x/a.mp4", language="en", codec=Audio.Codec.EC3, name="English")
audio.path = tmp_path / "a.mp4"
audio.path.write_bytes(b"\x00" * 16)
Tracks([video, audio])._mux_mp4(title="Film", output_path=tmp_path / "out.mkv")
command = mp4box_commands[0]
assert command[command.index("-name") + 1] == "3=English"
def test_an_mp4_mux_adds_only_the_own_stream_of_each_file(tmp_path: Path, mp4box_commands: list[list[str]]) -> None:
video = stereo_video(tmp_path, stereo=False)
video.data["own_stream_only"] = True
@@ -303,13 +255,6 @@ def test_an_mp4_mux_adds_only_the_own_stream_of_each_file(tmp_path: Path, mp4box
assert command[command.index("-name") + 1] == "2=English"
def test_a_3d_mux_that_loses_its_second_view_warns(
tmp_path: Path, mp4box_commands: list[list[str]], caplog: pytest.LogCaptureFixture
) -> None:
Tracks(stereo_video(tmp_path))._mux_mp4(title="Film", output_path=tmp_path / "out.mkv")
assert "lost its second view" in caplog.text
def test_a_downloaded_file_with_a_second_view_marks_the_video_3d(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
@@ -340,11 +285,3 @@ shared.m3u8
"""
tracks = HLS.from_text(master, url="https://cdn.example/master.m3u8").to_tracks(Language.get("en"))
assert any(v.stereo for v in tracks.videos)
def test_a_sample_is_cut_only_from_a_matroska_file(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
runner = dl.__new__(dl)
runner.log = logging.getLogger("download")
monkeypatch.setattr(subprocess, "run", lambda *a, **k: pytest.fail("mkvmerge ran on an MP4"))
runner.write_sample(tmp_path / "Film.mp4", SimpleNamespace(), SimpleNamespace())
assert not (tmp_path / "Sample").exists()