Files
AI/ontology_platform/tests/unit/test_dedup_cache.py
LASTA_DEV01\lasta e260e5f218 docs
2026-05-19 20:31:52 +09:00

33 lines
927 B
Python

from __future__ import annotations
from ont_platform.storage.dedup_cache import InMemoryDedupCache
def test_dedup_cache_remembers_project_scoped_fingerprint() -> None:
cache = InMemoryDedupCache()
first = cache.check_and_remember(
project_id="proj_1",
document_id="doc_a",
content_hash="hash-a",
fingerprint="fingerprint-a",
)
second = cache.check_and_remember(
project_id="proj_1",
document_id="doc_b",
content_hash="hash-b",
fingerprint="fingerprint-a",
)
other_project = cache.check_and_remember(
project_id="proj_2",
document_id="doc_c",
content_hash="hash-c",
fingerprint="fingerprint-a",
)
assert first.is_duplicate is False
assert second.is_duplicate is True
assert second.existing_document_id == "doc_a"
assert other_project.is_duplicate is False
assert len(cache) == 2