test(release): adapt suite to explicit ReleaseKnowledge injection
- test_release.py / test_release_fixtures.py: module-level _KB = YamlReleaseKnowledge() + thin _parse(name) helper threading it into parse_release. test_show_folder_name_strips_windows_chars renamed to test_show_folder_name_uses_already_safe_title to reflect the Option B contract (caller sanitizes via kb.sanitize_for_fs). - test_detect_media_type.py: same _KB pattern, all detect_media_type(parsed, path) calls now pass kb. - test_filesystem_extras.py: find_video_file(path) calls now pass kb. - test_enrich_from_probe.py: _bare() helper adds the new title_sanitized field. - test_resolve_destination.py: drop _sanitize import + TestSanitize class (helper deleted), add tmdb_title_safe arg to _resolve_series_folder calls. 987 passed, 8 skipped.
This commit is contained in:
@@ -9,7 +9,6 @@ Four use cases compute library paths from a release name + TMDB metadata:
|
||||
|
||||
Coverage:
|
||||
|
||||
- ``TestSanitize`` — Windows-forbidden chars stripped.
|
||||
- ``TestFindExistingTvshowFolders`` — empty root, prefix match (case + space → dot).
|
||||
- ``TestResolveSeriesFolderInternal`` — confirmed_folder, no existing, single match,
|
||||
ambiguous → _Clarification.
|
||||
@@ -32,7 +31,6 @@ from alfred.application.filesystem.resolve_destination import (
|
||||
_Clarification,
|
||||
_find_existing_tvshow_folders,
|
||||
_resolve_series_folder,
|
||||
_sanitize,
|
||||
resolve_episode_destination,
|
||||
resolve_movie_destination,
|
||||
resolve_season_destination,
|
||||
@@ -51,15 +49,6 @@ REL_SERIES = "Oz.Complete.Series.1080p.WEBRip.x265-KONTRAST"
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
|
||||
class TestSanitize:
|
||||
def test_passthrough_safe_chars(self):
|
||||
assert _sanitize("Oz.1997.1080p-GRP") == "Oz.1997.1080p-GRP"
|
||||
|
||||
def test_strips_windows_forbidden(self):
|
||||
# ? : * " < > | \
|
||||
assert _sanitize('a?b:c*d"e<f>g|h\\i') == "abcdefghi"
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# _find_existing_tvshow_folders #
|
||||
# --------------------------------------------------------------------------- #
|
||||
@@ -107,6 +96,7 @@ class TestResolveSeriesFolderInternal:
|
||||
out = _resolve_series_folder(
|
||||
tmp_path,
|
||||
"Oz",
|
||||
"Oz",
|
||||
1997,
|
||||
"Oz.1997.WEBRip-KONTRAST",
|
||||
confirmed_folder="Oz.1997.X-GRP",
|
||||
@@ -117,6 +107,7 @@ class TestResolveSeriesFolderInternal:
|
||||
out = _resolve_series_folder(
|
||||
tmp_path,
|
||||
"Oz",
|
||||
"Oz",
|
||||
1997,
|
||||
"Oz.1997.WEBRip-KONTRAST",
|
||||
confirmed_folder="Oz.1997.New-X",
|
||||
@@ -125,21 +116,21 @@ class TestResolveSeriesFolderInternal:
|
||||
|
||||
def test_no_existing_returns_computed_as_new(self, tmp_path):
|
||||
out = _resolve_series_folder(
|
||||
tmp_path, "Oz", 1997, "Oz.1997.WEBRip-KONTRAST", None
|
||||
tmp_path, "Oz", "Oz", 1997, "Oz.1997.WEBRip-KONTRAST", None
|
||||
)
|
||||
assert out == ("Oz.1997.WEBRip-KONTRAST", True)
|
||||
|
||||
def test_single_existing_matching_computed_returns_existing(self, tmp_path):
|
||||
(tmp_path / "Oz.1997.WEBRip-KONTRAST").mkdir()
|
||||
out = _resolve_series_folder(
|
||||
tmp_path, "Oz", 1997, "Oz.1997.WEBRip-KONTRAST", None
|
||||
tmp_path, "Oz", "Oz", 1997, "Oz.1997.WEBRip-KONTRAST", None
|
||||
)
|
||||
assert out == ("Oz.1997.WEBRip-KONTRAST", False)
|
||||
|
||||
def test_single_existing_different_name_returns_clarification(self, tmp_path):
|
||||
(tmp_path / "Oz.1997.BluRay-OTHER").mkdir()
|
||||
out = _resolve_series_folder(
|
||||
tmp_path, "Oz", 1997, "Oz.1997.WEBRip-KONTRAST", None
|
||||
tmp_path, "Oz", "Oz", 1997, "Oz.1997.WEBRip-KONTRAST", None
|
||||
)
|
||||
assert isinstance(out, _Clarification)
|
||||
assert "Oz" in out.question
|
||||
@@ -149,7 +140,7 @@ class TestResolveSeriesFolderInternal:
|
||||
def test_multiple_existing_returns_clarification(self, tmp_path):
|
||||
(tmp_path / "Oz.1997.A-GRP").mkdir()
|
||||
(tmp_path / "Oz.1997.B-GRP").mkdir()
|
||||
out = _resolve_series_folder(tmp_path, "Oz", 1997, "Oz.1997.A-GRP", None)
|
||||
out = _resolve_series_folder(tmp_path, "Oz", "Oz", 1997, "Oz.1997.A-GRP", None)
|
||||
assert isinstance(out, _Clarification)
|
||||
# Computed already in existing → not duplicated.
|
||||
assert out.options.count("Oz.1997.A-GRP") == 1
|
||||
|
||||
Reference in New Issue
Block a user