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"]
|
||||
Reference in New Issue
Block a user