fix: use configured collection in recovery paths
This commit is contained in:
committed by
Igor Lins e Silva
parent
88493acd0d
commit
ec6d2dde01
@@ -484,6 +484,26 @@ class TestWriteTools:
|
||||
assert result2["success"] is True
|
||||
assert result2["reason"] == "already_exists"
|
||||
|
||||
def test_add_drawer_fails_when_readback_misses(self, monkeypatch, config, kg):
|
||||
_patch_mcp_server(monkeypatch, config, kg)
|
||||
from mempalace import mcp_server
|
||||
|
||||
class _FakeGetResult:
|
||||
ids = []
|
||||
|
||||
class _FakeCol:
|
||||
def get(self, **kwargs):
|
||||
return _FakeGetResult()
|
||||
|
||||
def upsert(self, **kwargs):
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(mcp_server, "_get_collection", lambda create=False: _FakeCol())
|
||||
|
||||
result = mcp_server.tool_add_drawer("w", "r", "content")
|
||||
assert result["success"] is False
|
||||
assert "not readable" in result["error"]
|
||||
|
||||
def test_add_drawer_shared_header_no_collision(self, monkeypatch, config, palace_path, kg):
|
||||
"""Documents sharing a >100-char header must get distinct IDs (full-content hash)."""
|
||||
_patch_mcp_server(monkeypatch, config, kg)
|
||||
@@ -503,9 +523,9 @@ class TestWriteTools:
|
||||
|
||||
assert result1["success"] is True
|
||||
assert result2["success"] is True
|
||||
assert (
|
||||
result1["drawer_id"] != result2["drawer_id"]
|
||||
), "Documents with shared header but different content must have distinct drawer IDs"
|
||||
assert result1["drawer_id"] != result2["drawer_id"], (
|
||||
"Documents with shared header but different content must have distinct drawer IDs"
|
||||
)
|
||||
|
||||
def test_delete_drawer(self, monkeypatch, config, palace_path, seeded_collection, kg):
|
||||
_patch_mcp_server(monkeypatch, config, kg)
|
||||
@@ -1158,6 +1178,25 @@ class TestCacheInvalidation:
|
||||
assert "Reconnected" in result["message"]
|
||||
assert isinstance(result["drawers"], int)
|
||||
|
||||
def test_reconnect_closes_shared_backend(self, monkeypatch, config, kg):
|
||||
_patch_mcp_server(monkeypatch, config, kg)
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from mempalace import mcp_server, palace
|
||||
|
||||
close_palace = MagicMock()
|
||||
monkeypatch.setattr(palace._DEFAULT_BACKEND, "close_palace", close_palace)
|
||||
|
||||
class _FakeCol:
|
||||
def count(self):
|
||||
return 7
|
||||
|
||||
monkeypatch.setattr(mcp_server, "_get_collection", lambda create=False: _FakeCol())
|
||||
|
||||
result = mcp_server.tool_reconnect()
|
||||
assert result["success"] is True
|
||||
close_palace.assert_called_once_with(config.palace_path)
|
||||
|
||||
def test_get_collection_create_true_avoids_get_or_create_on_reopen(
|
||||
self, monkeypatch, config, palace_path, kg
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user