Add duplicate audio comparison controls
This commit is contained in:
+37
-1
@@ -3,7 +3,13 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from serato_doctor.web import STATIC_FILES, analyze_paths, duplicate_repair
|
||||
from serato_doctor.web import (
|
||||
STATIC_FILES,
|
||||
_file_token,
|
||||
_verified_audio,
|
||||
analyze_paths,
|
||||
duplicate_repair,
|
||||
)
|
||||
|
||||
|
||||
def test_web_analysis_uses_production_health_pipeline(tmp_path):
|
||||
@@ -77,3 +83,33 @@ def test_duplicate_repair_preview_does_not_change_files(tmp_path):
|
||||
assert result["database_v2_modified"] is False
|
||||
assert second.read_bytes() == b"second"
|
||||
assert not second.is_symlink()
|
||||
|
||||
|
||||
def test_audio_preview_tokens_only_open_signed_audio(tmp_path):
|
||||
track = tmp_path / "Track.mp3"
|
||||
track.write_bytes(b"audio")
|
||||
|
||||
token = _file_token(track)
|
||||
|
||||
assert _verified_audio(token) == track
|
||||
with pytest.raises(ValueError, match="Invalid or expired"):
|
||||
_verified_audio(token + "changed")
|
||||
|
||||
|
||||
def test_duplicate_details_include_preview_and_finder_controls(tmp_path):
|
||||
serato = tmp_path / "_Serato_"
|
||||
serato.mkdir()
|
||||
music = tmp_path / "Music"
|
||||
first = music / "A" / "Track.mp3"
|
||||
second = music / "B" / "Track.mp3"
|
||||
first.parent.mkdir(parents=True)
|
||||
second.parent.mkdir(parents=True)
|
||||
first.write_bytes(b"first")
|
||||
second.write_bytes(b"second")
|
||||
|
||||
result = analyze_paths(serato, music)
|
||||
group = result["details"]["duplicate_filenames"]["items"][0]
|
||||
|
||||
assert len(group["file_previews"]) == 2
|
||||
assert group["file_previews"][0]["audio_url"].startswith("/api/audio?")
|
||||
assert group["file_previews"][0]["reveal_token"]
|
||||
|
||||
Reference in New Issue
Block a user