Skip to content

Commit 0e993ae

Browse files
committed
test: cover brief() empty-palace and dedup behavior
Adds two tests to back the brief() retrieval mode: - test_brief_empty_palace: verifies brief() surfaces L2's "no drawers" message instead of crashing when the palace has no data - test_brief_dedupes_near_identical_drawers: verifies the >70% word overlap dedup actually collapses duplicates while preserving distinct content
1 parent 77a4e02 commit 0e993ae

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

tests/test_searcher.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,30 @@ def test_brief(self, palace_path, seeded_collection):
197197
assert "Brief" in result
198198
assert "topics" in result
199199

200+
def test_brief_empty_palace(self, palace_path, collection):
201+
"""Brief surfaces the L2 'no drawers' message instead of crashing."""
202+
result = brief(palace_path=palace_path)
203+
assert result.startswith("No ")
204+
205+
def test_brief_dedupes_near_identical_drawers(self, palace_path, collection):
206+
"""Brief collapses drawers whose summary lines overlap heavily."""
207+
collection.add(
208+
ids=["dup_a", "dup_b", "distinct_c"],
209+
documents=[
210+
"The authentication module uses JWT tokens for session management.",
211+
"The authentication module uses JWT tokens for session management.",
212+
"Database migrations are handled by Alembic with PostgreSQL 15.",
213+
],
214+
metadatas=[
215+
{"wing": "project", "room": "backend", "source_file": "auth_a.py"},
216+
{"wing": "project", "room": "backend", "source_file": "auth_b.py"},
217+
{"wing": "project", "room": "backend", "source_file": "db.py"},
218+
],
219+
)
220+
result = brief(palace_path=palace_path, wing="project")
221+
assert result.count("authentication module uses JWT") == 1
222+
assert "Database migrations" in result
223+
200224
def test_search_memories_query_error(self):
201225
"""search_memories returns error dict when query raises."""
202226
mock_col = MagicMock()

0 commit comments

Comments
 (0)