test: add memory database tests and update conftest for DB isolation

conftest patches mdb._DB_PATH and calls init_db() after directory creation
so all existing tests continue to work with the new DB layer. New
test_memory_db.py covers upsert, search, remove, migration, and the
updated list_memories/lookup_memories integration paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
curo1305
2026-05-18 15:23:57 +02:00
parent b9b0918d3a
commit 399ed8b5df
2 changed files with 124 additions and 0 deletions
+5
View File
@@ -28,6 +28,7 @@ def tmp_pyra_home(tmp_path, monkeypatch):
import pyra.plugins.loader as pl
import pyra.plugins.executor as pe
import pyra.memory.database as mdb
b.VAULT_PATH = fake_home / "vault"
b.BLOCKED_PREFIXES = [b.VAULT_PATH]
@@ -35,6 +36,8 @@ def tmp_pyra_home(tmp_path, monkeypatch):
mi._INDEX_FILE = fake_home / "memory" / "MEMORY_INDEX.md"
mr._MEMORY_ROOT = fake_home / "memory"
mw._MEMORY_ROOT = fake_home / "memory"
mdb._DB_PATH = fake_home / "memory" / "memory.db"
mdb._MEMORY_ROOT = fake_home / "memory"
vr._KEYS_FILE = fake_home / "vault" / "secrets" / "api_keys.json"
vw._KEYS_FILE = fake_home / "vault" / "secrets" / "api_keys.json"
si._LOG_FILE = fake_home / "security.log"
@@ -52,6 +55,8 @@ def tmp_pyra_home(tmp_path, monkeypatch):
(fake_home / "plugins").mkdir()
(fake_home / "logs").mkdir()
mdb.init_db()
# Reset plugin registry singleton so tests don't share state
from pyra.plugins.registry import PluginRegistry
PluginRegistry.reset()