Add duplicate audio hash detection
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
from serato_doctor.hashing import compare_audio_files, sha256_file
|
||||
|
||||
|
||||
def test_equal_files_have_the_same_hash(tmp_path):
|
||||
first = tmp_path / "First.mp3"
|
||||
second = tmp_path / "Second.mp3"
|
||||
first.write_bytes(b"same audio bytes")
|
||||
second.write_bytes(b"same audio bytes")
|
||||
|
||||
result = compare_audio_files((first, second))
|
||||
|
||||
assert result["status"] == "identical"
|
||||
assert sha256_file(first) == sha256_file(second)
|
||||
|
||||
|
||||
def test_different_files_are_not_reported_as_identical(tmp_path):
|
||||
first = tmp_path / "First.mp3"
|
||||
second = tmp_path / "Second.mp3"
|
||||
first.write_bytes(b"version one")
|
||||
second.write_bytes(b"version two")
|
||||
|
||||
result = compare_audio_files((first, second))
|
||||
|
||||
assert result["status"] == "different"
|
||||
assert result["files"][0]["sha256"] != result["files"][1]["sha256"]
|
||||
@@ -143,5 +143,6 @@ def test_batch_preview_combines_approved_groups_without_changes(tmp_path):
|
||||
assert len(result["replaced"]) == 2
|
||||
assert len(result["decisions"]) == 2
|
||||
assert result["decisions"][0]["keeper"].endswith("First.mp3")
|
||||
assert result["decisions"][0]["hash_status"] == "different"
|
||||
assert len(result["decisions"][0]["replaced"]) == 1
|
||||
assert all(not Path(choice["group_files"][1]).is_symlink() for choice in choices)
|
||||
|
||||
Reference in New Issue
Block a user