[AZ-175] Media table integration with XxHash64 content hashing and status lifecycle

Made-with: Cursor
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-03-31 06:36:56 +03:00
parent 6c24d09eab
commit 40be55ac03
10 changed files with 381 additions and 30 deletions
+46
View File
@@ -0,0 +1,46 @@
import xxhash
def test_compute_media_content_hash_small_file():
# Arrange
from media_hash import compute_media_content_hash
data = b"x" * 100
expected = xxhash.xxh64(len(data).to_bytes(8, "little") + data).hexdigest()
# Act
out = compute_media_content_hash(data)
# Assert
assert out == expected
def test_compute_media_content_hash_large_file():
# Arrange
from media_hash import compute_media_content_hash
data = (bytes(range(256)) * 20)[:5000]
n = len(data)
mid = (n - 1024) // 2
blob = (
n.to_bytes(8, "little")
+ data[0:1024]
+ data[mid : mid + 1024]
+ data[-1024:]
)
expected = xxhash.xxh64(blob).hexdigest()
# Act
out = compute_media_content_hash(data)
# Assert
assert out == expected
def test_compute_media_content_hash_virtual_prefix():
# Arrange
from media_hash import compute_media_content_hash
# Act
v = compute_media_content_hash(b"abc", virtual=True)
n = compute_media_content_hash(b"abc", virtual=False)
# Assert
assert v.startswith("V")
assert not n.startswith("V")
assert v == "V" + n