initial commit heh

This commit is contained in:
timka123 committed 2026-11-07 22:34:12 +03:00
commit 5eea9d0f2c
78 files changed
+11181

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
"""Unit tests for Global Shared Memory."""
from homeagent.memory.global_memory import GlobalMemory
def test_global_memory_crud_and_search(tmp_path):
storage_file = tmp_path / "global_memory.json"
mem = GlobalMemory(storage_file)
# 1. Add facts
item1 = mem.add_fact("Пользователь предпочитает короткие ответы", category="user")
item2 = mem.add_fact("Основной проект в Jira: PROJ", category="jira")
assert len(mem.list_facts()) == 2
# 2. Search
results = mem.search("Jira")
assert len(results) == 1
assert results[0].id == item2.id
# 3. Category filter
user_facts = mem.list_facts(category="user")
assert len(user_facts) == 1
assert user_facts[0].id == item1.id
# 4. Persistence check
mem2 = GlobalMemory(storage_file)
assert len(mem2.list_facts()) == 2
# 5. Summary formatting
summary = mem2.get_memory_summary()
assert "[ГЛОБАЛЬНАЯ ПАМЯТЬ" in summary
assert "PROJ" in summary
# 6. Delete
assert mem2.remove_fact(item1.id)
assert len(mem2.list_facts()) == 1