fix(tests): update search service mock to match current API signature (#2334)
comprehensive_web_search now called with (query, max_pages, return_sources) and returns a tuple (_context, results). The test mock still used the old async signature with max_results/fetch_content and returned a plain list, causing TypeError on every run. Fixes #2331
This commit is contained in:
@@ -3,18 +3,18 @@ import asyncio
|
|||||||
import services.search.service as svc_mod
|
import services.search.service as svc_mod
|
||||||
from services.search.service import SearchService
|
from services.search.service import SearchService
|
||||||
|
|
||||||
|
|
||||||
def test_search_skips_non_dict_results(monkeypatch):
|
def test_search_skips_non_dict_results(monkeypatch):
|
||||||
# comprehensive_web_search aggregates external provider + cache results;
|
# comprehensive_web_search aggregates external provider + cache results;
|
||||||
# a malformed row (string/None) made the old loop call r.get and crash,
|
# a malformed row (string/None) made the old loop call r.get and crash,
|
||||||
# losing the whole search.
|
# losing the whole search.
|
||||||
async def fake_search(query, max_results=10, fetch_content=False):
|
def fake_search(query, max_pages=10, return_sources=False):
|
||||||
return [
|
results = [
|
||||||
{"url": "https://a.com", "title": "A", "snippet": "x"},
|
{"url": "https://a.com", "title": "A"},
|
||||||
"junk-row",
|
"junk-row",
|
||||||
None,
|
None,
|
||||||
{"url": "https://b.com", "title": "B", "snippet": "y"},
|
{"url": "https://b.com", "title": "B"},
|
||||||
]
|
]
|
||||||
|
return ("", results)
|
||||||
|
|
||||||
monkeypatch.setattr(svc_mod, "comprehensive_web_search", fake_search)
|
monkeypatch.setattr(svc_mod, "comprehensive_web_search", fake_search)
|
||||||
svc = SearchService()
|
svc = SearchService()
|
||||||
|
|||||||
Reference in New Issue
Block a user