Add defensible orphaned audio detection

This commit is contained in:
Philip Guzman
2026-07-02 16:17:11 -07:00
parent 4d04939846
commit 22c4f58646
9 changed files with 133 additions and 11 deletions
+28
View File
@@ -2,6 +2,7 @@ from pathlib import Path
from serato_doctor.health import analyze_health
from serato_doctor.models.crate import Crate, CrateKind
from serato_doctor.models.database import DatabaseTrack, SeratoDatabase
from serato_doctor.models.filesystem import BrokenSymlink
from serato_doctor.models.library import Library
from serato_doctor.models.reference import TrackReference
@@ -49,6 +50,7 @@ def test_health_report_exposes_each_metric():
assert report.duplicate_filename_groups == 1
assert report.duplicate_files == 1
assert report.unused_tracks == 3
assert report.orphan_candidates is None
assert report.suggested_matches == 1
@@ -60,6 +62,32 @@ def test_empty_library_has_no_health_score():
assert report.scored_references == 0
assert not report.database_present
assert report.tracks_missing_from_database == 0
assert report.orphan_candidates is None
def test_orphan_candidates_exclude_tracks_known_to_serato_or_crates():
tracks = [
track("Crated.mp3"),
track("LibraryOnly.mp3"),
track("OutsideEverything.mp3"),
]
database = SeratoDatabase(
Path("database V2"),
"test",
(
DatabaseTrack(
Path("/new/House/LibraryOnly.mp3"), "LibraryOnly.mp3"
),
),
)
library = Library.build(
[reference("Crated.mp3")], tracks, database=database
)
report = analyze_health(library)
assert report.unused_tracks == 2
assert report.orphan_candidates == 1
def test_smart_crate_references_are_reported_but_not_scored():
+3
View File
@@ -37,6 +37,8 @@ def test_web_analysis_uses_production_health_pipeline(tmp_path):
assert result["details"]["old_crate_references"]["items"][0]["crate"]
assert result["details"]["suggested_matches"]["total"] == 0
assert result["details"]["unused_tracks"]["total"] == 1
assert result["orphan_candidates"] == 0
assert result["details"]["orphan_candidates"]["assessed"] is True
def test_web_analysis_rejects_missing_folders(tmp_path):
@@ -58,6 +60,7 @@ def test_web_static_assets_are_declared_and_packaged():
html = (asset_root / "index.html").read_text(encoding="utf-8")
assert "Missing tracks in Serato" in html
assert "Old crate references" in html
assert "Possible orphan files" in html
assert "Choose a diagnostic" in html
assert "Backup recovery" in html
assert "Heres exactly what will happen" in html