test: cover memory persistence and path isolation
This commit is contained in:
1 parent
f68dddf162
commit
9a4f4612d7
1 file changed
+24
@@ -0,0 +1,24 @@
|
|||||||
|
"""Regression tests for durable global memory."""
|
||||||
|
|
||||||
|
from homeagent.memory.global_memory import GlobalMemory, get_global_memory
|
||||||
|
|
||||||
|
|
||||||
|
def test_memory_survives_new_instance(tmp_path):
|
||||||
|
path = tmp_path / "data" / "global_memory.json"
|
||||||
|
memory = GlobalMemory(path)
|
||||||
|
item = memory.add_fact("сохранить после рестарта", category="reliability")
|
||||||
|
|
||||||
|
restarted = GlobalMemory(path)
|
||||||
|
assert restarted.search("рестарта")[0].id == item.id
|
||||||
|
assert not list(path.parent.glob("*.tmp"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_memory_uses_distinct_paths(tmp_path):
|
||||||
|
first_path = tmp_path / "one" / "global_memory.json"
|
||||||
|
second_path = tmp_path / "two" / "global_memory.json"
|
||||||
|
first = get_global_memory(first_path)
|
||||||
|
second = get_global_memory(second_path)
|
||||||
|
|
||||||
|
assert first is not second
|
||||||
|
first.add_fact("только в первом")
|
||||||
|
assert second.list_facts() == []
|
||||||
Reference in new issue
Block a user