Files
serato-doctor/tests/test_hashing.py
2026-07-01 16:36:21 -07:00

26 lines
811 B
Python

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"]