fix: address Copilot review — derive MCP version, improve test isolation and portability
This commit is contained in:
+6
-1
@@ -37,7 +37,8 @@ from mempalace.knowledge_graph import KnowledgeGraph # noqa: E402
|
|||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def _reset_mcp_cache():
|
def _reset_mcp_cache():
|
||||||
"""Reset the MCP server's cached ChromaDB client/collection between tests."""
|
"""Reset the MCP server's cached ChromaDB client/collection between tests."""
|
||||||
yield
|
|
||||||
|
def _clear_cache():
|
||||||
try:
|
try:
|
||||||
from mempalace import mcp_server
|
from mempalace import mcp_server
|
||||||
|
|
||||||
@@ -46,6 +47,10 @@ def _reset_mcp_cache():
|
|||||||
except (ImportError, AttributeError):
|
except (ImportError, AttributeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
_clear_cache()
|
||||||
|
yield
|
||||||
|
_clear_cache()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session", autouse=True)
|
@pytest.fixture(scope="session", autouse=True)
|
||||||
def _isolate_home():
|
def _isolate_home():
|
||||||
|
|||||||
@@ -151,9 +151,10 @@ class TestReadTools:
|
|||||||
assert result["taxonomy"]["project"]["frontend"] == 1
|
assert result["taxonomy"]["project"]["frontend"] == 1
|
||||||
assert result["taxonomy"]["notes"]["planning"] == 1
|
assert result["taxonomy"]["notes"]["planning"] == 1
|
||||||
|
|
||||||
def test_no_palace_returns_error(self, monkeypatch, config, kg):
|
def test_no_palace_returns_error(self, monkeypatch, config, kg, tmp_path):
|
||||||
config._file_config["palace_path"] = "/nonexistent/path"
|
missing = str(tmp_path / "missing")
|
||||||
_patch_mcp_server(monkeypatch, config, "/nonexistent/path", kg)
|
config._file_config["palace_path"] = missing
|
||||||
|
_patch_mcp_server(monkeypatch, config, missing, kg)
|
||||||
from mempalace.mcp_server import tool_status
|
from mempalace.mcp_server import tool_status
|
||||||
|
|
||||||
result = tool_status()
|
result = tool_status()
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ class TestSearchMemories:
|
|||||||
result = search_memories("code", palace_path, n_results=2)
|
result = search_memories("code", palace_path, n_results=2)
|
||||||
assert len(result["results"]) <= 2
|
assert len(result["results"]) <= 2
|
||||||
|
|
||||||
def test_no_palace_returns_error(self):
|
def test_no_palace_returns_error(self, tmp_path):
|
||||||
result = search_memories("anything", "/nonexistent/path")
|
result = search_memories("anything", str(tmp_path / "missing"))
|
||||||
assert "error" in result
|
assert "error" in result
|
||||||
|
|
||||||
def test_result_fields(self, palace_path, seeded_collection):
|
def test_result_fields(self, palace_path, seeded_collection):
|
||||||
|
|||||||
Reference in New Issue
Block a user