test(mcp): migrate _kg monkeypatches to _get_kg (#1136)
Direct module-attribute patching of _kg is obsolete after the lazy cache refactor. Switch test helpers to patch _get_kg instead so the fixture KG replaces the factory rather than a now-missing singleton. - tests/test_mcp_server.py: _patch_mcp_server helper - tests/benchmarks/test_mcp_bench.py: _patch_mcp_config helper - tests/benchmarks/test_memory_profile.py: inline patch in test_tool_status_repeated_calls
This commit is contained in:
@@ -40,8 +40,9 @@ def _patch_mcp_config(monkeypatch, palace_path, tmp_path):
|
|||||||
|
|
||||||
import mempalace.mcp_server as mcp_mod
|
import mempalace.mcp_server as mcp_mod
|
||||||
|
|
||||||
|
kg = KnowledgeGraph(db_path=str(tmp_path / "kg.sqlite3"))
|
||||||
monkeypatch.setattr(mcp_mod, "_config", cfg)
|
monkeypatch.setattr(mcp_mod, "_config", cfg)
|
||||||
monkeypatch.setattr(mcp_mod, "_kg", KnowledgeGraph(db_path=str(tmp_path / "kg.sqlite3")))
|
monkeypatch.setattr(mcp_mod, "_get_kg", lambda: kg)
|
||||||
|
|
||||||
|
|
||||||
def _get_rss_mb():
|
def _get_rss_mb():
|
||||||
|
|||||||
@@ -84,8 +84,9 @@ class TestToolStatusMemoryProfile:
|
|||||||
|
|
||||||
cfg = MempalaceConfig(config_dir=str(tmp_path / "cfg"))
|
cfg = MempalaceConfig(config_dir=str(tmp_path / "cfg"))
|
||||||
monkeypatch.setattr(cfg, "_file_config", {"palace_path": palace_path})
|
monkeypatch.setattr(cfg, "_file_config", {"palace_path": palace_path})
|
||||||
|
kg = KnowledgeGraph(db_path=str(tmp_path / "kg.sqlite3"))
|
||||||
monkeypatch.setattr(mcp_mod, "_config", cfg)
|
monkeypatch.setattr(mcp_mod, "_config", cfg)
|
||||||
monkeypatch.setattr(mcp_mod, "_kg", KnowledgeGraph(db_path=str(tmp_path / "kg.sqlite3")))
|
monkeypatch.setattr(mcp_mod, "_get_kg", lambda: kg)
|
||||||
|
|
||||||
from mempalace.mcp_server import tool_status
|
from mempalace.mcp_server import tool_status
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ def _patch_mcp_server(monkeypatch, config, kg):
|
|||||||
from mempalace import mcp_server
|
from mempalace import mcp_server
|
||||||
|
|
||||||
monkeypatch.setattr(mcp_server, "_config", config)
|
monkeypatch.setattr(mcp_server, "_config", config)
|
||||||
monkeypatch.setattr(mcp_server, "_kg", kg)
|
monkeypatch.setattr(mcp_server, "_get_kg", lambda: kg)
|
||||||
|
|
||||||
|
|
||||||
def _get_collection(palace_path, create=False):
|
def _get_collection(palace_path, create=False):
|
||||||
|
|||||||
Reference in New Issue
Block a user