MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / test_hash_registry_remove_by_doc_name

Function test_hash_registry_remove_by_doc_name

tests/test_remove.py:203–221  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

201
202
203def test_hash_registry_remove_by_doc_name(tmp_path):
204 path = tmp_path / "hashes.json"
205 path.write_text(
206 json.dumps(
207 {
208 "h1": {"name": "a.pdf", "doc_name": "a-h1", "type": "short"},
209 "h2": {"name": "b.pdf", "doc_name": "b-h2", "type": "short"},
210 }
211 )
212 )
213
214 reg = HashRegistry(path)
215 assert reg.remove_by_doc_name("a-h1") is True
216 assert reg.remove_by_doc_name("a-h1") is False # already gone
217 assert "h2" in reg.all_entries() and "h1" not in reg.all_entries()
218
219 # Persisted to disk
220 saved = json.loads(path.read_text())
221 assert list(saved.keys()) == ["h2"]
222
223
224def test_hash_registry_remove_by_hash(tmp_path):

Callers

nothing calls this directly

Calls 3

remove_by_doc_nameMethod · 0.95
all_entriesMethod · 0.95
HashRegistryClass · 0.90

Tested by

no test coverage detected