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:
@@ -34,6 +34,9 @@ from alfred.infrastructure.filesystem.filesystem_operations import (
|
||||
)
|
||||
from alfred.infrastructure.filesystem.find_video import find_video_file
|
||||
from alfred.infrastructure.filesystem.organizer import MediaOrganizer
|
||||
from alfred.infrastructure.knowledge.release_kb import YamlReleaseKnowledge
|
||||
|
||||
_KB = YamlReleaseKnowledge()
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# ffprobe.probe #
|
||||
@@ -263,35 +266,35 @@ class TestFindVideo:
|
||||
def test_returns_file_directly_when_video(self, tmp_path):
|
||||
f = tmp_path / "Movie.mkv"
|
||||
f.write_bytes(b"")
|
||||
assert find_video_file(f) == f
|
||||
assert find_video_file(f, _KB) == f
|
||||
|
||||
def test_returns_none_when_file_is_not_video(self, tmp_path):
|
||||
f = tmp_path / "notes.txt"
|
||||
f.write_text("x")
|
||||
assert find_video_file(f) is None
|
||||
assert find_video_file(f, _KB) is None
|
||||
|
||||
def test_returns_none_when_folder_has_no_video(self, tmp_path):
|
||||
(tmp_path / "a.txt").write_text("x")
|
||||
assert find_video_file(tmp_path) is None
|
||||
assert find_video_file(tmp_path, _KB) is None
|
||||
|
||||
def test_returns_first_sorted_video(self, tmp_path):
|
||||
(tmp_path / "B.mkv").write_bytes(b"")
|
||||
(tmp_path / "A.mkv").write_bytes(b"")
|
||||
(tmp_path / "C.mkv").write_bytes(b"")
|
||||
found = find_video_file(tmp_path)
|
||||
found = find_video_file(tmp_path, _KB)
|
||||
assert found.name == "A.mkv"
|
||||
|
||||
def test_recurses_into_subfolders(self, tmp_path):
|
||||
sub = tmp_path / "sub"
|
||||
sub.mkdir()
|
||||
(sub / "X.mkv").write_bytes(b"")
|
||||
found = find_video_file(tmp_path)
|
||||
found = find_video_file(tmp_path, _KB)
|
||||
assert found is not None and found.name == "X.mkv"
|
||||
|
||||
def test_case_insensitive_extension(self, tmp_path):
|
||||
f = tmp_path / "Movie.MKV"
|
||||
f.write_bytes(b"")
|
||||
assert find_video_file(f) == f
|
||||
assert find_video_file(f, _KB) == f
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
Reference in New Issue
Block a user