MCPcopy
hub / github.com/MemPalace/mempalace / test_closet_purge_runs_on_apply

Method test_closet_purge_runs_on_apply

tests/test_sync.py:368–409  ·  view source on GitHub ↗

Closets pointing at removed sources must also disappear.

(self, synced_world)

Source from the content-addressed store, hash-verified

366 del client
367
368 def test_closet_purge_runs_on_apply(self, synced_world):
369 """Closets pointing at removed sources must also disappear."""
370 from mempalace.sync import sync_palace
371
372 # Seed a closet referencing the to-be-pruned ignored.py source.
373 client = chromadb.PersistentClient(path=synced_world["palace_path"])
374 closets = client.get_or_create_collection(
375 "mempalace_closets", metadata={"hnsw:space": "cosine"}
376 )
377 ignored_path = str(Path(synced_world["repo_path"]) / "build" / "ignored.py")
378 closets.add(
379 ids=["closet_ignored_01"],
380 documents=["topic line"],
381 embeddings=[[1.0, 0.0, 0.0]],
382 metadatas=[
383 {
384 "wing": "demo",
385 "room": "build",
386 "source_file": ignored_path,
387 "chunk_index": 0,
388 "added_by": "miner",
389 "filed_at": "2026-05-09T00:00:00",
390 }
391 ],
392 )
393 del client
394
395 report = sync_palace(
396 palace_path=synced_world["palace_path"],
397 project_dirs=[synced_world["repo_path"]],
398 dry_run=False,
399 )
400 assert report["removed_closets"] >= 1
401
402 client = chromadb.PersistentClient(path=synced_world["palace_path"])
403 closets = client.get_or_create_collection(
404 "mempalace_closets", metadata={"hnsw:space": "cosine"}
405 )
406 try:
407 assert closets.get(ids=["closet_ignored_01"])["ids"] == []
408 finally:
409 del client
410
411 def test_handles_empty_palace(self, palace_path):
412 from mempalace.sync import sync_palace

Callers

nothing calls this directly

Calls 4

sync_palaceFunction · 0.90
addMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected