Files
alfred/tests/domain/test_release_fixtures.py
T
francwa 273510dff8 test(fixtures): seed PATH OF PAIN bucket with 10 worst-case fixtures
10 pathological release names mined from the real downloads folder.
Each fixture locks in the current parse_release output (including
its silent losses and false positives) so future parser improvements
are intentional, not silent drift.

Cases:
- Khruangbin yt-dlp slug (UTF-8 wide pipe '|', YT ID as group)
- Deutschland 83-86-89 franchise box (group=S03 misdetection)
- Chérie Le BéBé (accented chars preserved, VFF language)
- Jimmy Carr 8-word stand-up special title
- [ OxTorrent.vc ] prefix + XviD codec (site_tag prefix)
- Prodiges S12E01 with episode title + air-date silently lost
- The Prodigy: apostrophe + Blu-ray dash + 1080i + multi-word audio
  = full AI-path degeneration (everything UNKNOWN)
- Sleaford Mods yt-dlp slug (YT ID glued to year)
- Super Mario Bros [FR-EN] (bilingual tag mistaken for group)
- Gilmore Girls Complete S01-S07 (the well-behaved exception:
  COMPLETE token correctly drives tv_complete + REPACK + 10bit)

Also adds shitty + path_of_pain to the per-bucket sanity assertion.

Suite: 1020 passed, 8 skipped.
2026-05-18 15:57:56 +02:00

57 lines
2.2 KiB
Python

"""Real-world release fixtures — anti-regression baseline for parse_release.
Each fixture under ``tests/fixtures/releases/<bucket>/<case>/expected.yaml``
declares a release name and the ``ParsedRelease`` fields it should produce.
Fields absent from the fixture's ``parsed`` block are not checked, so adding
new attributes to ``ParsedRelease`` never breaks existing fixtures.
The fixture's ``tree`` is materialized into a temp dir to prove the layout is
self-consistent, even though no filesystem assertions are made yet. The
``routing`` block (library / torrents / seed_hardlinks) is captured ahead of
the ``organize_media`` refactor — it will become verifiable once the planner
exists.
"""
from __future__ import annotations
from dataclasses import asdict
import pytest
from alfred.domain.release.services import parse_release
from tests.fixtures.releases.conftest import ReleaseFixture, discover_fixtures
FIXTURES = discover_fixtures()
@pytest.mark.parametrize(
"fixture",
FIXTURES,
ids=[f.name for f in FIXTURES],
)
def test_parse_matches_fixture(fixture: ReleaseFixture, tmp_path) -> None:
# Materialize the tree to assert it is at least well-formed YAML +
# plausible filesystem paths. Catches typos / missing leading dirs early.
fixture.materialize(tmp_path)
result = asdict(parse_release(fixture.release_name))
# ``is_season_pack`` is a @property — asdict() does not include it.
result["is_season_pack"] = parse_release(fixture.release_name).is_season_pack
for field, expected in fixture.expected_parsed.items():
assert field in result, (
f"{fixture.name}: unknown field '{field}' in expected.parsed"
)
assert result[field] == expected, (
f"{fixture.name}: parsed.{field}"
f"expected {expected!r}, got {result[field]!r}"
)
def test_at_least_one_fixture_per_bucket() -> None:
"""Each bucket should hold at least one case once populated."""
buckets = {f.name.split("/")[0] for f in FIXTURES}
assert "easy" in buckets, "EASY bucket must have at least one fixture"
assert "shitty" in buckets, "SHITTY bucket must have at least one fixture"
assert "path_of_pain" in buckets, "PATH_OF_PAIN bucket must have at least one fixture"