Files
odysseus/tests/test_search_service_nondict_rows.py
raf d3e6935d62 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
2026-06-04 14:19:51 +01:00

24 lines
866 B
Python

import asyncio
import services.search.service as svc_mod
from services.search.service import SearchService
def test_search_skips_non_dict_results(monkeypatch):
# comprehensive_web_search aggregates external provider + cache results;
# a malformed row (string/None) made the old loop call r.get and crash,
# losing the whole search.
def fake_search(query, max_pages=10, return_sources=False):
results = [
{"url": "https://a.com", "title": "A"},
"junk-row",
None,
{"url": "https://b.com", "title": "B"},
]
return ("", results)
monkeypatch.setattr(svc_mod, "comprehensive_web_search", fake_search)
svc = SearchService()
res = asyncio.run(svc.search("anything"))
assert [r.url for r in res.results] == ["https://a.com", "https://b.com"]
assert res.total == 2