from __future__ import annotations from pathlib import Path from app.utils.hashing import sha256_file def test_two_files_with_same_content_share_sha(tmp_path: Path): a = tmp_path / "a.pdf" b = tmp_path / "b.pdf" payload = b"%PDF-1.4\n" + b"x" * 4096 a.write_bytes(payload) b.write_bytes(payload) assert sha256_file(a) == sha256_file(b) def test_one_byte_difference_changes_sha(tmp_path: Path): a = tmp_path / "a.pdf" b = tmp_path / "b.pdf" a.write_bytes(b"%PDF-1.4\n" + b"x" * 4096) b.write_bytes(b"%PDF-1.4\n" + b"x" * 4095 + b"y") assert sha256_file(a) != sha256_file(b)