"""Unit tests for DocumentHasher.""" from pathlib import Path from app.dedup.hasher import DocumentHasher def test_compute_sha256(sample_pdf: Path) -> None: h1 = DocumentHasher.compute_sha256(sample_pdf) h2 = DocumentHasher.compute_sha256(sample_pdf) assert len(h1) == 64 assert h1 == h2 def test_compute_simhash() -> None: text1 = "Khmer document corpus testing text" text2 = "Khmer document corpus testing text extra" text3 = "Unrelated contents entirely" s1 = DocumentHasher.compute_simhash(text1) s2 = DocumentHasher.compute_simhash(text2) s3 = DocumentHasher.compute_simhash(text3) assert isinstance(s1, int) assert s1 != s3 assert s2 != s3