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:
@@ -46,7 +46,6 @@ def _bare(**overrides) -> ParsedRelease:
|
||||
source=None,
|
||||
codec=None,
|
||||
group="UNKNOWN",
|
||||
tech_string="",
|
||||
)
|
||||
defaults.update(overrides)
|
||||
return ParsedRelease(**defaults)
|
||||
@@ -218,8 +217,9 @@ class TestLanguages:
|
||||
|
||||
|
||||
class TestTechString:
|
||||
"""tech_string drives the filename builders; it must be re-derived
|
||||
whenever quality / source / codec change."""
|
||||
"""tech_string is a derived property on ParsedRelease: it always
|
||||
reflects the current quality/source/codec. Enrichment never writes
|
||||
it directly — it stays in sync by construction."""
|
||||
|
||||
def test_rebuilt_from_filled_quality_and_codec(self):
|
||||
p = _bare()
|
||||
@@ -239,9 +239,9 @@ class TestTechString:
|
||||
assert p.tech_string == "1080p.BluRay.x265"
|
||||
|
||||
def test_unchanged_when_no_enrichable_video_info(self):
|
||||
# No video info → nothing to fill → tech_string stays as it was.
|
||||
# No video info → nothing to fill → derived tech_string stays as it was.
|
||||
p = _bare(quality="2160p", source="WEB-DL", codec="x265")
|
||||
p.tech_string = "2160p.WEB-DL.x265"
|
||||
assert p.tech_string == "2160p.WEB-DL.x265"
|
||||
enrich_from_probe(p, MediaInfo())
|
||||
assert p.tech_string == "2160p.WEB-DL.x265"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user