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
-111
View File
@@ -17,63 +17,12 @@ import yaml
from click.testing import CliRunner
from unshackle.commands import setup as setup_mod
from unshackle.commands.env import get_dependencies
from unshackle.core import binaries
from unshackle.core.config import Config, config
EXT = ".exe" if sys.platform == "win32" else ""
@pytest.mark.parametrize(
("tool", "system", "machine", "suffix"),
[
("shaka-packager", "linux", "x86_64", "/v2.6.1/packager-linux-x64"),
("shaka-packager", "linux", "aarch64", "/v2.6.1/packager-linux-arm64"),
("shaka-packager", "win32", "AMD64", "/v2.6.1/packager-win-x64.exe"),
("FFmpeg", "linux", "x86_64", "-linux64-gpl.tar.xz"),
("FFmpeg", "win32", "AMD64", "-win64-gpl.zip"),
("MKVToolNix", "win32", "AMD64", "mkvtoolnix-64-bit-102.0.zip"),
("dovi_tool", "linux", "arm64", "-aarch64-unknown-linux-musl.tar.gz"),
("CCExtractor", "linux", "x86_64", "/v0.96.6/ccextractor-minimal-x86_64.AppImage"),
("CCExtractor", "win32", "AMD64", "/v0.96.6/CCExtractor.0.96.6_win_portable.zip"),
],
)
def test_asset_url_matches_platform(tool: str, system: str, machine: str, suffix: str) -> None:
url = setup_mod.asset_url(tool, system, machine)
assert url is not None and url.startswith("https://") and url.endswith(suffix)
@pytest.mark.parametrize(
("tool", "system", "machine"),
[
("MKVToolNix", "linux", "x86_64"),
("CCExtractor", "linux", "aarch64"),
("mp4decrypt", "linux", "aarch64"),
("shaka-packager", "darwin", "arm64"),
("FFmpeg", "win32", "ARM64"),
],
)
def test_asset_url_is_none_without_a_portable_build(tool: str, system: str, machine: str) -> None:
assert setup_mod.asset_url(tool, system, machine) is None
def test_every_url_and_hint_is_filled_from_the_version() -> None:
for tool, spec in setup_mod.TOOLS.items():
hint = setup_mod.versioned(tool, spec["hint"])
assert hint and "{" not in hint
for key in spec["urls"]:
url = setup_mod.asset_url(tool, *key.split("-", 1))
assert url is not None and url.startswith("https://") and "{" not in url
assert spec["version"].replace(".", "-") in url or spec["version"] in url
def test_label_shows_pinned_versions_only() -> None:
assert setup_mod.label("shaka-packager") == "shaka-packager 2.6.1"
assert setup_mod.label("FFmpeg") == "FFmpeg"
assert setup_mod.label("CCExtractor", "linux") == "CCExtractor 0.96.6"
assert setup_mod.label("CCExtractor", "win32") == "CCExtractor 0.96.6, 88 MB"
def make_zip(path: Path, members: dict[str, bytes]) -> Path:
with zipfile.ZipFile(path, "w") as zf:
for name, data in members.items():
@@ -132,15 +81,6 @@ def test_extract_moves_a_lone_binary(tmp_path: Path) -> None:
assert not download.exists()
def test_is_clone_follows_pyproject(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
package = tmp_path / "unshackle"
package.mkdir()
monkeypatch.setattr(config.directories, "namespace_dir", package)
assert setup_mod.is_clone() is False
(tmp_path / "pyproject.toml").write_text("")
assert setup_mod.is_clone() is True
def test_write_config_tool_mode_moves_data_dirs(tmp_path: Path) -> None:
path = tmp_path / "config" / "unshackle.yaml"
data_root = tmp_path / "data"
@@ -181,13 +121,6 @@ def make_exe(folder: Path, name: str) -> Path:
return path
def test_find_checks_the_user_binaries_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(binaries, "user_binaries_dir", tmp_path / "user")
tool = make_exe(tmp_path / "user", "setup-test-tool")
assert binaries.find("setup-test-tool") == tool
def test_find_prefers_the_package_binaries_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(binaries, "package_binaries_dir", tmp_path / "unshackle" / "binaries")
monkeypatch.setattr(binaries, "user_binaries_dir", tmp_path / "user")
@@ -255,18 +188,6 @@ def fake_deps(missing: Iterable[str]) -> list[dict[str, object]]:
]
def test_tools_deps_exist_in_env_check(monkeypatch: pytest.MonkeyPatch) -> None:
# Set in the module dict: a setattr reads the old value first, and that read runs the PATH search.
for attr in set(binaries.__all__) - {"find", "register", "get_registered_dependencies"}:
monkeypatch.setitem(vars(binaries), attr, None)
deps = {dep["name"]: dep["required"] for dep in get_dependencies()}
names = {dep for spec in setup_mod.TOOLS.values() for dep in spec["deps"]}
assert names <= deps.keys()
assert {name for name in names if deps[name]} == REQUIRED_DEPS
@pytest.fixture
def sandbox(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> SimpleNamespace:
"""Point every path setup touches into tmp_path and record its prompts and installs.
@@ -424,13 +345,6 @@ def test_device_files_expands_a_folder_without_recursion(tmp_path: Path) -> None
assert setup_mod.device_files(str(make_devices(tmp_path / "empty", {}))) == []
def test_device_files_keeps_quotes_and_home(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("HOME", str(tmp_path))
monkeypatch.setenv("USERPROFILE", str(tmp_path))
assert setup_mod.device_files('"~/x.wvd"') == [tmp_path / "x.wvd"]
@pytest.mark.usefixtures("fake_devices")
def test_cdm_prompt_repeats_and_asks_for_the_default(
sandbox: SimpleNamespace, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
@@ -468,21 +382,6 @@ def test_one_bad_device_does_not_stop_the_rest(
assert not (sandbox.package / "WVDs" / "bad.wvd").exists()
@pytest.mark.usefixtures("fake_devices")
def test_folder_without_devices_says_so(
sandbox: SimpleNamespace, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
# Longer than the 80-column console, so a wrapped line would split the path.
folder = make_devices(tmp_path / ("long" * 20) / "in", {"notes.txt": b""})
script_cdm_prompts(monkeypatch, [str(folder)])
result = CliRunner().invoke(setup_mod.setup, [])
assert result.exit_code == 0, result.output
assert f"No .wvd or .prd files in {folder}" in result.output
assert "cdm" not in yaml.safe_load((sandbox.package / "unshackle.yaml").read_text())
@pytest.mark.usefixtures("fake_devices")
def test_destination_folder_is_already_in_place(sandbox: SimpleNamespace, monkeypatch: pytest.MonkeyPatch) -> None:
wvds = make_devices(sandbox.package / "WVDs", {"x.wvd": b"device"})
@@ -592,13 +491,3 @@ def test_appimage_is_kept_only_when_it_runs(
output = capsys.readouterr().out
assert "the AppImage does not run, it needs FUSE" in output
assert "Install it manually: see the fake docs" in output
def test_group_prompt_shows_the_download_size(sandbox: SimpleNamespace, monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setitem(setup_mod.TOOLS["CCExtractor"], "size", "88 MB")
monkeypatch.setattr(setup_mod, "get_dependencies", lambda: fake_deps({"SubtitleEdit", "CCExtractor"}))
result = CliRunner().invoke(setup_mod.setup, [])
assert result.exit_code == 0, result.output
assert sandbox.prompts == [("Install the Subtitle tools (SubtitleEdit 5.2.0, CCExtractor 0.96.6, 88 MB)?", False)]