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
-116
View File
@@ -5,7 +5,6 @@ from typing import Any
import click
import pytest
import rich_click
from click.testing import CliRunner
from pyplayready import main as prd_upstream
from pywidevine import main as wvd_upstream
@@ -35,59 +34,6 @@ def files(folder: Path, *names: str) -> Path:
return folder
def test_prd_new_from_a_folder_passes_its_files_and_saves_into_the_folder(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
folder = files(tmp_path / "dev", "zgpriv.dat", "bgroupcert.dat")
calls = record(monkeypatch, prd_upstream, "create_device")
result = CliRunner().invoke(prd_module.prd, ["new", str(folder)])
assert result.exit_code == 0, result.output
assert calls == [
{
"group_key": folder / "zgpriv.dat",
"protected_group_key": None,
"group_certificate": folder / "bgroupcert.dat",
"encryption_key": None,
"signing_key": None,
"output": folder,
}
]
assert set(calls[0]) == names(prd_upstream, "create_device")
def test_prd_new_from_two_paths_passes_the_keys_and_output(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
src = files(tmp_path, "key.dat", "cert.dat", "enc.dat", "sig.dat")
monkeypatch.setattr(config.directories, "prds", tmp_path / "PRDs")
calls = record(monkeypatch, prd_upstream, "create_device")
result = CliRunner().invoke(
prd_module.prd,
[
"new",
str(src / "key.dat"),
str(src / "cert.dat"),
"-e",
str(src / "enc.dat"),
"-s",
str(src / "sig.dat"),
"-o",
str(tmp_path / "out.prd"),
],
)
default = CliRunner().invoke(prd_module.prd, ["new", str(src / "key.dat"), str(src / "cert.dat")])
assert result.exit_code == 0, result.output
assert default.exit_code == 0, default.output
assert calls[1]["output"] == tmp_path / "PRDs"
assert calls[0]["group_key"] == src / "key.dat"
assert calls[0]["group_certificate"] == src / "cert.dat"
assert calls[0]["encryption_key"] == src / "enc.dat"
assert calls[0]["signing_key"] == src / "sig.dat"
assert calls[0]["output"] == tmp_path / "out.prd"
@pytest.mark.parametrize(
("args", "message"),
[
@@ -111,53 +57,6 @@ def test_prd_new_refuses_bad_paths_before_the_upstream_command(
assert calls == []
def test_prd_reprovision_passes_its_arguments(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
device = files(tmp_path, "d.prd") / "d.prd"
calls = record(monkeypatch, prd_upstream, "reprovision_device")
result = CliRunner().invoke(prd_module.prd, ["reprovision", str(device), "-o", str(tmp_path / "new.prd")])
assert result.exit_code == 0, result.output
assert calls == [{"prd_path": device, "encryption_key": None, "signing_key": None, "output": tmp_path / "new.prd"}]
assert set(calls[0]) == names(prd_upstream, "reprovision_device")
def test_prd_test_sends_the_upstream_content_key_type(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
device = files(tmp_path, "d.prd") / "d.prd"
calls = record(monkeypatch, prd_upstream, "test")
result = CliRunner().invoke(prd_module.prd, ["test", str(device), "-c", "AESCBC", "-sl", "3000"])
assert result.exit_code == 0, result.output
assert calls == [{"device": device, "ckt": "AES128BitCBC", "security_level": "3000"}]
ckt = next(param for param in prd_upstream.test.params if param.name == "ckt")
assert set(prd_module.CONTENT_KEY_TYPES.values()) == set(ckt.type.choices)
assert set(calls[0]) == names(prd_upstream, "test")
def test_prd_lists_the_upstream_export_and_inspect_commands() -> None:
assert prd_module.prd.commands["export"] is prd_upstream.export_device
assert prd_module.prd.commands["inspect"] is prd_upstream.inspect
def test_wvd_dump_exports_each_device_and_resolves_a_bare_name_in_the_wvds_directory(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setattr(config.directories, "wvds", files(tmp_path / "WVDs", "example.wvd"))
monkeypatch.chdir(tmp_path)
other = files(tmp_path / "elsewhere", "other.wvd") / "other.wvd"
calls = record(monkeypatch, wvd_upstream, "export_device")
result = CliRunner().invoke(wvd_module.wvd, ["dump", "example", str(other), "out"])
assert result.exit_code == 0, result.output
assert calls == [
{"wvd_path": tmp_path / "WVDs" / "example.wvd", "out_dir": Path("out")},
{"wvd_path": other, "out_dir": Path("out")},
]
assert set(calls[0]) == names(wvd_upstream, "export_device")
def test_wvd_dump_names_a_missing_device_path(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(config.directories, "wvds", tmp_path / "WVDs")
calls = record(monkeypatch, wvd_upstream, "export_device")
@@ -167,18 +66,3 @@ def test_wvd_dump_names_a_missing_device_path(tmp_path: Path, monkeypatch: pytes
assert isinstance(result.exception, click.UsageError)
assert str(tmp_path / "WVDs" / "missing.wvd") in result.exception.message
assert calls == []
def test_ctx_invoke_runs_a_command_of_another_package_in_a_sub_context() -> None:
seen: list[tuple[str | None, int]] = []
foreign = rich_click.RichCommand(
"foreign",
params=[click.Option(["--value"], type=int, default=5)],
callback=click.pass_context(lambda ctx, value: seen.append((ctx.info_name, value))),
)
outer = click.Command("outer", callback=lambda: click.get_current_context().invoke(foreign))
result = CliRunner().invoke(outer)
assert result.exit_code == 0, result.output
assert seen == [("foreign", 5)]