test: stop five API option tests reading the local config and binaries.

This commit is contained in:
imSp4rky
2026-11-25 17:01:15 -07:00
parent 35e0d827fa
commit 5b96918b7e
4 changed files with 11 additions and 4 deletions
+2 -1
View File
@@ -781,7 +781,8 @@ def test_the_hybrid_step_gets_the_base_alone_when_there_is_no_dv(tmp_path: Path)
assert len(tracks) == 1 and tracks[0].range == Video.Range.HDR10P
def test_the_api_takes_generate_dv_with_any_range_as_dl_does() -> None:
def test_the_api_takes_generate_dv_with_any_range_as_dl_does(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr("unshackle.core.binaries.DoviTool", Path("dovi_tool"))
for data in ({}, {"range": ["SDR"]}, {"range": ["DV"]}, {"range": ["HYBRID"]}, {"range": ["HDR10"]}):
assert validate_download_parameters({"generate_dv": True, **data}) is None
assert "boolean" in (validate_download_parameters({"generate_dv": "yes", "range": ["HYBRID"]}) or "")
+2 -1
View File
@@ -95,7 +95,8 @@ def test_api_refuses_two_ids(payload: dict) -> None:
@pytest.mark.parametrize("payload", [{"tmdb_id": 27205}, {"imdb_id": "tt1375666"}, {"tvdb_id": 73871}, {}])
def test_api_accepts_one_id(payload: dict) -> None:
def test_api_accepts_one_id(payload: dict, monkeypatch: pytest.MonkeyPatch) -> None:
with_keys(monkeypatch, tmdb_api_key="k", tvdb_api_key="k")
assert validate_download_parameters(payload) is None
+4 -1
View File
@@ -10,6 +10,7 @@ from click.core import ParameterSource
from unshackle.commands.dl import dl
from unshackle.core.api.errors import categorize_exception
from unshackle.core.config import config
from unshackle.core.remote_protocol import APIErrorCode
from unshackle.core.run_plan import PlanError, api_plan, bitrate_range, check_options
from unshackle.core.tracks import Video
@@ -101,6 +102,8 @@ def test_the_api_plan_records_where_each_value_came_from() -> None:
assert ctx.params == plan.params
def test_dl_checks_the_plan_before_the_service_loads() -> None:
@pytest.mark.usefixtures("example_service")
def test_dl_checks_the_plan_before_the_service_loads(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(config, "output_template", {"movies": "{title}"})
with pytest.raises(PlanError, match="--sample and --include-sample"):
dl.cli.main(["--sample", "--include-sample", "EXAMPLE", "t"], standalone_mode=False)
@@ -4,6 +4,7 @@ and the secret redaction applied to job parameters and error/stderr fields."""
from __future__ import annotations
from datetime import datetime
from pathlib import Path
import pytest
from aiohttp import web
@@ -163,7 +164,8 @@ async def test_credential_allowed_when_enabled(stub_handler):
assert isinstance(resp, web.Response)
def test_range_validation_accepts_hdr10p_and_alias():
def test_range_validation_accepts_hdr10p_and_alias(monkeypatch):
monkeypatch.setattr("unshackle.core.binaries.DoviTool", Path("dovi_tool"))
# canonical "HDR10P" and back-compat "HDR10+" both pass; mixed casing too
assert handlers.validate_download_parameters({"range": ["HDR10P", "DV", "SDR"]}) is None
assert handlers.validate_download_parameters({"range": ["hdr10+"]}) is None