mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-16 14:05:10 +00:00
docs: strip non-essential comments, fold key facts into docstrings
This commit is contained in:
@@ -82,9 +82,6 @@ def selected(result: Dict[str, Any]) -> List[str]:
|
||||
return keys
|
||||
|
||||
|
||||
# ---------- serialize_title: the JSON contract ----------
|
||||
|
||||
|
||||
def test_partless_episode_json_has_no_part_key() -> None:
|
||||
d = serialize_title(ep(part=None))
|
||||
assert "part" not in d
|
||||
@@ -137,9 +134,6 @@ def test_movie_json_unaffected() -> None:
|
||||
assert "part" not in d
|
||||
|
||||
|
||||
# ---------- list_tracks_handler: the REST wanted filter ----------
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def split_titles() -> List[Episode]:
|
||||
"""E1 split into three parts, E2 unsplit."""
|
||||
@@ -172,9 +166,6 @@ def test_rest_part_of_unsplit_episode_selects_nothing(monkeypatch, split_titles)
|
||||
assert result["status"] == 404
|
||||
|
||||
|
||||
# ---------- discrete season/episode/part request fields ----------
|
||||
|
||||
|
||||
def test_discrete_fields_without_part_select_every_part(monkeypatch, split_titles) -> None:
|
||||
result = run_list_tracks(monkeypatch, split_titles, season=1, episode=1)
|
||||
assert selected(result) == ["1x1.1", "1x1.2", "1x1.3"]
|
||||
@@ -207,18 +198,12 @@ def test_part_is_a_transport_key_not_a_service_option() -> None:
|
||||
assert "part" in handlers.SESSION_TRANSPORT_KEYS
|
||||
|
||||
|
||||
# ---------- ordering ----------
|
||||
|
||||
|
||||
def test_rest_multi_episode_order_is_stable_across_parts(monkeypatch) -> None:
|
||||
titles = [ep(1, 2, None), ep(1, 1, 3), ep(1, 1, 1), ep(1, 1, 2)]
|
||||
result = run_list_tracks(monkeypatch, titles, wanted="S01")
|
||||
assert selected(result) == ["1x1.1", "1x1.2", "1x1.3", "1x2"]
|
||||
|
||||
|
||||
# ---------- download_manager: already-internal wanted sniff ----------
|
||||
|
||||
|
||||
SNIFF = r"^!?\d+x\d+(\.\d+)?$"
|
||||
|
||||
|
||||
@@ -283,9 +268,6 @@ def test_perform_download_still_converts_cli_style_tokens(monkeypatch) -> None:
|
||||
assert params["wanted"] == ["1x1"]
|
||||
|
||||
|
||||
# ---------- CLI / REST agreement ----------
|
||||
|
||||
|
||||
def test_dl_and_handlers_share_the_one_match_helper() -> None:
|
||||
"""Both filters must route through Episode.matches_wanted, or they drift."""
|
||||
from pathlib import Path
|
||||
|
||||
@@ -49,9 +49,6 @@ def _movie(**overrides: Any) -> Movie:
|
||||
return Movie(**base)
|
||||
|
||||
|
||||
# ---------- serialize_title: the new conditional keys ----------
|
||||
|
||||
|
||||
NEW_KEYS = ("air_date", "absolute", "daily", "anime")
|
||||
|
||||
|
||||
@@ -94,9 +91,6 @@ def test_a_movie_carries_the_anime_flag_but_never_daily() -> None:
|
||||
assert "daily" not in d
|
||||
|
||||
|
||||
# ---------- the service-class ANIME/DAILY stamp ----------
|
||||
|
||||
|
||||
class _AnimeDailySvc:
|
||||
ANIME = True
|
||||
DAILY = True
|
||||
@@ -149,9 +143,6 @@ def test_list_titles_stamps_the_service_flags(monkeypatch: pytest.MonkeyPatch) -
|
||||
assert (title["anime"], title["daily"]) == (True, True)
|
||||
|
||||
|
||||
# ---------- round trips through build_title ----------
|
||||
|
||||
|
||||
def round_trip(episode: Episode, stamp: Optional[Any] = None) -> Episode:
|
||||
info = serialize_title(episode)
|
||||
if stamp is not None:
|
||||
@@ -196,9 +187,6 @@ def test_a_movie_round_trip_keeps_the_anime_flag() -> None:
|
||||
assert rebuilt.anime is True
|
||||
|
||||
|
||||
# ---------- round trips through title_to_meta (the export/import path) ----------
|
||||
|
||||
|
||||
def test_title_to_meta_omits_the_new_keys_for_a_plain_episode() -> None:
|
||||
meta = dl.title_to_meta(ep())
|
||||
assert not [k for k in ("absolute", "daily", "anime") if k in meta]
|
||||
|
||||
@@ -21,9 +21,6 @@ from unshackle.core.api.errors import APIError, APIErrorCode
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
# ---------- redaction ----------
|
||||
|
||||
|
||||
def test_redact_parameters_masks_secrets_and_proxy_userinfo():
|
||||
params = {
|
||||
"service": "ATV",
|
||||
@@ -85,9 +82,6 @@ def test_to_dict_full_details_redacts_error_fields_and_parameters():
|
||||
assert d["parameters"]["credential"] == "***"
|
||||
|
||||
|
||||
# ---------- gates ----------
|
||||
|
||||
|
||||
class _PastGate(Exception):
|
||||
"""Raised by the stubbed Services.load to prove a request got past the gate into the try block."""
|
||||
|
||||
@@ -140,9 +134,6 @@ async def test_credential_allowed_when_enabled(stub_handler):
|
||||
assert isinstance(resp, web.Response)
|
||||
|
||||
|
||||
# ---------- range validation ----------
|
||||
|
||||
|
||||
def test_range_validation_accepts_hdr10p_and_alias():
|
||||
# canonical "HDR10P" and back-compat "HDR10+" both pass; mixed casing too
|
||||
assert handlers.validate_download_parameters({"range": ["HDR10P", "DV", "SDR"]}) is None
|
||||
|
||||
@@ -142,7 +142,6 @@ def test_handle_api_exception_categorizes_generic() -> None:
|
||||
assert body["error_code"] == "NETWORK_ERROR"
|
||||
|
||||
|
||||
# --- Error contract harness (PRD 05 gate) ---------------------------------
|
||||
# Locks the FULL observable response — (http status, error_code, retryable) — that
|
||||
# a client sees for a generic (non-APIError) exception flowing through the
|
||||
# handle_api_exception funnel that every route's `except Exception` path calls.
|
||||
|
||||
@@ -77,9 +77,6 @@ def subtitle(**overrides) -> Subtitle:
|
||||
return Subtitle(**base)
|
||||
|
||||
|
||||
# ---------- sanitize_log ----------
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"raw, expected",
|
||||
[
|
||||
@@ -93,9 +90,6 @@ def test_sanitize_log(raw, expected: str) -> None:
|
||||
assert sanitize_log(raw) == expected
|
||||
|
||||
|
||||
# ---------- serialize_title ----------
|
||||
|
||||
|
||||
def test_serialize_title_movie() -> None:
|
||||
movie = Movie(id_="movie-0001", service=_FakeSvc, name="Title X", year=2024, language=Language.get("en"))
|
||||
d = serialize_title(movie)
|
||||
@@ -140,9 +134,6 @@ def test_serialize_title_episode_unnamed_falls_back_to_number() -> None:
|
||||
assert d["name"] == "Episode 05"
|
||||
|
||||
|
||||
# ---------- serialize_video/audio/subtitle ----------
|
||||
|
||||
|
||||
def test_serialize_video_track_basic() -> None:
|
||||
d = serialize_video_track(video())
|
||||
assert d["id"] == "video-001"
|
||||
@@ -179,9 +170,6 @@ def test_serialize_subtitle_track_basic() -> None:
|
||||
assert d["cc"] is False
|
||||
|
||||
|
||||
# ---------- serialize_drm ----------
|
||||
|
||||
|
||||
def test_serialize_drm_none_returns_none() -> None:
|
||||
assert serialize_drm(None) is None
|
||||
assert serialize_drm([]) is None
|
||||
@@ -224,16 +212,10 @@ def test_serialize_drm_playready_pssh_without_dumps_is_omitted() -> None:
|
||||
assert info["kids"] == ["00112233445566778899aabbccddeeff"]
|
||||
|
||||
|
||||
# ---------- validate_service ----------
|
||||
|
||||
|
||||
def test_validate_service_unknown_returns_none() -> None:
|
||||
assert validate_service("NOPE_THIS_IS_NOT_REAL_") is None
|
||||
|
||||
|
||||
# ---------- validate_download_parameters ----------
|
||||
|
||||
|
||||
def test_validate_download_params_accepts_defaults() -> None:
|
||||
assert validate_download_parameters({}) is None
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ from unshackle.core.api.progress import (
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
# --- lightweight track stand-ins (label/weight key off class name + attributes) ---
|
||||
class _Range:
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
Reference in New Issue
Block a user