|
5 | 5 | import pytest |
6 | 6 |
|
7 | 7 | from basic_memory.mcp.tools import write_note, read_note |
8 | | -from basic_memory.schemas.search import SearchResponse, SearchResult, SearchItemType |
9 | 8 | from basic_memory.utils import normalize_newlines |
10 | 9 |
|
11 | 10 |
|
@@ -68,30 +67,30 @@ async def test_read_note_returns_related_results_when_text_search_finds_matches( |
68 | 67 |
|
69 | 68 | async def fake_search_notes_fn(*, query, search_type, **kwargs): |
70 | 69 | if search_type == "title": |
71 | | - return SearchResponse(results=[], current_page=1, page_size=10) |
72 | | - |
73 | | - return SearchResponse( |
74 | | - results=[ |
75 | | - SearchResult( |
76 | | - title="Related One", |
77 | | - permalink="docs/related-one", |
78 | | - content="", |
79 | | - type=SearchItemType.ENTITY, |
80 | | - score=1.0, |
81 | | - file_path="docs/related-one.md", |
82 | | - ), |
83 | | - SearchResult( |
84 | | - title="Related Two", |
85 | | - permalink="docs/related-two", |
86 | | - content="", |
87 | | - type=SearchItemType.ENTITY, |
88 | | - score=0.9, |
89 | | - file_path="docs/related-two.md", |
90 | | - ), |
| 70 | + return {"results": [], "current_page": 1, "page_size": 10} |
| 71 | + |
| 72 | + return { |
| 73 | + "results": [ |
| 74 | + { |
| 75 | + "title": "Related One", |
| 76 | + "permalink": "docs/related-one", |
| 77 | + "content": "", |
| 78 | + "type": "entity", |
| 79 | + "score": 1.0, |
| 80 | + "file_path": "docs/related-one.md", |
| 81 | + }, |
| 82 | + { |
| 83 | + "title": "Related Two", |
| 84 | + "permalink": "docs/related-two", |
| 85 | + "content": "", |
| 86 | + "type": "entity", |
| 87 | + "score": 0.9, |
| 88 | + "file_path": "docs/related-two.md", |
| 89 | + }, |
91 | 90 | ], |
92 | | - current_page=1, |
93 | | - page_size=10, |
94 | | - ) |
| 91 | + "current_page": 1, |
| 92 | + "page_size": 10, |
| 93 | + } |
95 | 94 |
|
96 | 95 | # Ensure direct resolution doesn't short-circuit the fallback logic. |
97 | 96 | class FailingKnowledgeClient(OriginalKnowledgeClient): |
@@ -131,21 +130,21 @@ async def resolve_entity(self, identifier: str, *, strict: bool = False) -> int: |
131 | 130 |
|
132 | 131 | async def fake_search_notes_fn(*, query, search_type, **kwargs): |
133 | 132 | if search_type == "title": |
134 | | - return SearchResponse( |
135 | | - results=[ |
136 | | - SearchResult( |
137 | | - title="Existing Note", |
138 | | - permalink="test/existing-note", |
139 | | - content="", |
140 | | - type=SearchItemType.ENTITY, |
141 | | - score=1.0, |
142 | | - file_path="test/Existing Note.md", |
143 | | - ) |
| 133 | + return { |
| 134 | + "results": [ |
| 135 | + { |
| 136 | + "title": "Existing Note", |
| 137 | + "permalink": "test/existing-note", |
| 138 | + "content": "", |
| 139 | + "type": "entity", |
| 140 | + "score": 1.0, |
| 141 | + "file_path": "test/Existing Note.md", |
| 142 | + } |
144 | 143 | ], |
145 | | - current_page=1, |
146 | | - page_size=10, |
147 | | - ) |
148 | | - return SearchResponse(results=[], current_page=1, page_size=10) |
| 144 | + "current_page": 1, |
| 145 | + "page_size": 10, |
| 146 | + } |
| 147 | + return {"results": [], "current_page": 1, "page_size": 10} |
149 | 148 |
|
150 | 149 | monkeypatch.setattr(clients_mod, "KnowledgeClient", StrictFailingKnowledgeClient) |
151 | 150 | monkeypatch.setattr(read_note_module.search_notes, "fn", fake_search_notes_fn) |
|
0 commit comments