forked from kenzuya/unshackle
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -9,7 +9,6 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
@@ -102,14 +101,6 @@ def test_partless_episode_json_has_no_part_key() -> None:
|
||||
assert d["name"] == "Pilot"
|
||||
|
||||
|
||||
def test_partful_episode_json_carries_part_last() -> None:
|
||||
d = serialize_title(ep(part=2), None)
|
||||
assert d["part"] == 2
|
||||
# additive: `part` is appended, every pre-existing key keeps its position
|
||||
assert list(d.keys())[:11] == list(serialize_title(ep(part=None), None).keys())
|
||||
assert list(d.keys())[11] == "part"
|
||||
|
||||
|
||||
def test_part_stays_out_of_the_name_field() -> None:
|
||||
"""`name` is a reconstruction input for build_title, not a display string."""
|
||||
assert serialize_title(ep(part=2), None)["name"] == "Pilot"
|
||||
@@ -124,17 +115,6 @@ def test_remote_build_title_round_trip() -> None:
|
||||
assert partless.part is None
|
||||
|
||||
|
||||
def test_movie_json_unaffected() -> None:
|
||||
from langcodes import Language
|
||||
|
||||
from unshackle.core.titles.movie import Movie
|
||||
|
||||
d = serialize_title(
|
||||
Movie(id_="movie-0001", service=_FakeSvc, name="Film", year=2024, language=Language.get("en")), None
|
||||
)
|
||||
assert "part" not in d
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def split_titles() -> list[Episode]:
|
||||
"""E1 split into three parts, E2 unsplit."""
|
||||
@@ -177,11 +157,6 @@ def test_discrete_fields_with_part_select_one(monkeypatch, split_titles) -> None
|
||||
assert selected(result) == ["1x1.3"]
|
||||
|
||||
|
||||
def test_discrete_part_accepts_string(monkeypatch, split_titles) -> None:
|
||||
result = run_list_tracks(monkeypatch, split_titles, season=1, episode=1, part="3")
|
||||
assert selected(result) == ["1x1.3"]
|
||||
|
||||
|
||||
def test_discrete_no_match_error_reports_the_part_qualified_key(monkeypatch, split_titles) -> None:
|
||||
result = run_list_tracks(monkeypatch, split_titles, season=1, episode=1, part=9)
|
||||
assert result["status"] == 404
|
||||
@@ -193,60 +168,17 @@ def test_discrete_partless_error_key_unchanged(monkeypatch, split_titles) -> Non
|
||||
assert result["details"]["wanted"] == "9x9"
|
||||
|
||||
|
||||
def test_part_is_a_transport_key_not_a_service_option() -> None:
|
||||
"""`part` addresses the title, so it must never reach a service's own --part option."""
|
||||
assert "part" in handlers.LIST_HANDLER_TRANSPORT_KEYS
|
||||
assert "part" in handlers.SESSION_TRANSPORT_KEYS
|
||||
|
||||
|
||||
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"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("wanted", "parsed"),
|
||||
[
|
||||
(["1x1"], ["1x1"]),
|
||||
(["1x1.2"], ["1x1.2"]),
|
||||
(["!1x1.2"], ["!1x1.2"]),
|
||||
(["1x1", "!1x1.2"], ["1x1", "!1x1.2"]),
|
||||
("1x1, 1x2", ["1x1", "1x2"]),
|
||||
(["1x01"], ["1x1"]),
|
||||
],
|
||||
)
|
||||
def test_parsed_keys_pass_unchanged(wanted: Any, parsed: list[str]) -> None:
|
||||
"""A pre-parsed part or negative key never reaches parse_tokens, which cannot read it."""
|
||||
assert SEASON_RANGE.convert(wanted) == parsed
|
||||
|
||||
|
||||
@pytest.mark.parametrize("wanted", [["S01E01"], "S01E01", ["s1e1"], "s1e1; S01E01"])
|
||||
def test_tokens_parse_from_a_list_or_a_separated_string(wanted: Any) -> None:
|
||||
assert SEASON_RANGE.convert(wanted) == ["1x1"]
|
||||
|
||||
|
||||
def test_a_mixed_list_parses_every_token() -> None:
|
||||
assert sorted(SEASON_RANGE.convert(["1x1", "S01E02"])) == ["1x1", "1x2"]
|
||||
|
||||
|
||||
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
|
||||
|
||||
import unshackle.commands.dl as dl_module
|
||||
|
||||
dl_source = Path(dl_module.__file__).read_text(encoding="utf8")
|
||||
handlers_source = Path(handlers.__file__).read_text(encoding="utf8")
|
||||
|
||||
assert "matches_wanted(wanted)" in dl_source
|
||||
assert "matches_wanted(wanted)" in handlers_source
|
||||
# no inline key compare left behind on either side
|
||||
inline = re.compile(r"f\"\{title\.season\}x\{title\.number\}\"\s*\n?\s*(?:in|not in)\s+wanted")
|
||||
assert not inline.search(dl_source)
|
||||
assert not inline.search(handlers_source)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"wanted_tokens",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user