fix: use configured collection in recovery paths
This commit is contained in:
committed by
Igor Lins e Silva
parent
88493acd0d
commit
ec6d2dde01
+22
-4
@@ -84,6 +84,24 @@ class TestSearchMemories:
|
||||
assert "error" in result
|
||||
assert "query failed" in result["error"]
|
||||
|
||||
def test_search_memories_vector_path_uses_explicit_collection_name(self):
|
||||
mock_col = MagicMock()
|
||||
mock_col.query.return_value = {
|
||||
"documents": [[]],
|
||||
"metadatas": [[]],
|
||||
"distances": [[]],
|
||||
"ids": [[]],
|
||||
}
|
||||
|
||||
with patch("mempalace.searcher.get_collection", return_value=mock_col) as get_collection:
|
||||
search_memories("test", "/fake/path", collection_name="custom_drawers")
|
||||
|
||||
get_collection.assert_called_once_with(
|
||||
"/fake/path",
|
||||
collection_name="custom_drawers",
|
||||
create=False,
|
||||
)
|
||||
|
||||
def test_search_memories_filters_in_result(self, palace_path, seeded_collection):
|
||||
result = search_memories("test", palace_path, wing="project", room="backend")
|
||||
assert result["filters"]["wing"] == "project"
|
||||
@@ -102,7 +120,7 @@ class TestSearchMemories:
|
||||
"ids": [["d1", "d2"]],
|
||||
}
|
||||
|
||||
def mock_get_collection(path, create=False):
|
||||
def mock_get_collection(path, collection_name=None, create=False):
|
||||
# First call: drawers. Second call: closets — raise so hybrid
|
||||
# degrades to pure drawer search (the catch block covers it).
|
||||
if not hasattr(mock_get_collection, "_called"):
|
||||
@@ -309,9 +327,9 @@ class TestSearchCLI:
|
||||
captured = capsys.readouterr()
|
||||
first_block, _, _ = captured.out.partition("[2]")
|
||||
# Lexical match must rank first
|
||||
assert (
|
||||
"b.md" in first_block
|
||||
), f"expected lexical match 'b.md' at rank 1, got:\n{captured.out}"
|
||||
assert "b.md" in first_block, (
|
||||
f"expected lexical match 'b.md' at rank 1, got:\n{captured.out}"
|
||||
)
|
||||
# Non-zero bm25 reported
|
||||
assert "bm25=" in first_block
|
||||
assert "bm25=0.0" not in first_block
|
||||
|
||||
Reference in New Issue
Block a user