refactor(release): make tech_string a derived property
ParsedRelease.tech_string was a stored str field re-computed in two
places (assemble() at parse time, enrich_from_probe() after the probe).
The second site was a reactive fix (e79ca46) for filename builders that
saw a stale value. Turn it into an @property so it stays in sync with
quality/source/codec by construction.
- Drop the field from the dataclass + the key from assemble()'s dict.
- Drop tech_string="" from parse_release's malformed-name fallback.
- Drop the manual recomputation at the end of enrich_from_probe.
- Inject the property into asdict() result in the fixtures runner
(same treatment as is_season_pack).
- Update tests that passed tech_string= to the constructor; rewrite the
TestTechString case that mutated p.tech_string manually.
This commit is contained in:
@@ -123,7 +123,6 @@ class TestAssemble:
|
||||
assert fields["source"] == "WEBRip"
|
||||
assert fields["codec"] == "x265"
|
||||
assert fields["group"] == "KONTRAST"
|
||||
assert fields["tech_string"] == "1080p.WEBRip.x265"
|
||||
assert fields["media_type"] == "movie"
|
||||
assert fields["site_tag"] is None
|
||||
|
||||
@@ -150,7 +149,8 @@ class TestAssemble:
|
||||
assert fields["season"] == 2
|
||||
assert fields["episode"] is None # season pack
|
||||
assert fields["source"] is None # ELiTE omits it
|
||||
assert fields["tech_string"] == "1080p.x265"
|
||||
assert fields["quality"] == "1080p"
|
||||
assert fields["codec"] == "x265"
|
||||
assert fields["group"] == "ELiTE"
|
||||
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ def _movie(year: int = 2020, **overrides) -> ParsedRelease:
|
||||
source="BluRay",
|
||||
codec="x264",
|
||||
group="GROUP",
|
||||
tech_string="1080p.BluRay.x264",
|
||||
media_type=MediaTypeToken.MOVIE,
|
||||
parse_path=ParsePath.DIRECT,
|
||||
)
|
||||
@@ -120,7 +119,6 @@ class TestComputeScore:
|
||||
source="WEBRip",
|
||||
codec="x265",
|
||||
group="KONTRAST",
|
||||
tech_string="1080p.WEBRip.x265",
|
||||
media_type=MediaTypeToken.TV_SHOW,
|
||||
parse_path=ParsePath.DIRECT,
|
||||
)
|
||||
@@ -231,7 +229,6 @@ class TestCollectors:
|
||||
source=None,
|
||||
codec=None,
|
||||
group="UNKNOWN",
|
||||
tech_string="",
|
||||
media_type=MediaTypeToken.UNKNOWN,
|
||||
parse_path=ParsePath.DIRECT,
|
||||
)
|
||||
|
||||
@@ -44,8 +44,10 @@ def test_parse_matches_fixture(fixture: ReleaseFixture, tmp_path) -> None:
|
||||
|
||||
parsed, _report = parse_release(fixture.release_name, _KB)
|
||||
result = asdict(parsed)
|
||||
# ``is_season_pack`` is a @property — asdict() does not include it.
|
||||
# ``is_season_pack`` and ``tech_string`` are @property values —
|
||||
# ``asdict()`` does not include them.
|
||||
result["is_season_pack"] = parsed.is_season_pack
|
||||
result["tech_string"] = parsed.tech_string
|
||||
|
||||
for field, expected in fixture.expected_parsed.items():
|
||||
assert field in result, (
|
||||
|
||||
Reference in New Issue
Block a user