fix search runs with empty results
This commit is contained in:
@@ -69,6 +69,27 @@ def test_searxng_provider_normalizes_json_results() -> None:
|
||||
asyncio.run(run())
|
||||
|
||||
|
||||
def test_searxng_provider_sends_configured_engine_allow_list() -> None:
|
||||
async def run() -> None:
|
||||
seen_request: httpx.Request | None = None
|
||||
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
nonlocal seen_request
|
||||
seen_request = request
|
||||
return httpx.Response(200, json={"results": []})
|
||||
|
||||
provider = SearXNGProvider("http://searxng:8080", engines=("bing", "yahoo"))
|
||||
provider._client = httpx.AsyncClient(transport=httpx.MockTransport(handler))
|
||||
try:
|
||||
await provider.search("test")
|
||||
assert seen_request is not None
|
||||
assert seen_request.url.params["engines"] == "bing,yahoo"
|
||||
finally:
|
||||
await provider._client.aclose()
|
||||
|
||||
asyncio.run(run())
|
||||
|
||||
|
||||
def test_orchestrator_registers_searxng_provider() -> None:
|
||||
orchestrator = ResearchOrchestrator(_config(), uuid4(), "test")
|
||||
provider = orchestrator._get_multi_search().get_provider("searxng")
|
||||
@@ -104,6 +125,25 @@ def test_searching_accepts_normalized_result_with_empty_snippet() -> None:
|
||||
asyncio.run(run())
|
||||
|
||||
|
||||
def test_searching_with_no_usable_results_fails_instead_of_completing_empty() -> None:
|
||||
"""Provider-wide empty results must not become an empty completed report."""
|
||||
async def run() -> None:
|
||||
orchestrator = ResearchOrchestrator(_config(), uuid4(), "test")
|
||||
multi_search = Mock()
|
||||
multi_search.enabled_providers.return_value = ["searxng"]
|
||||
multi_search.search = AsyncMock(return_value=[])
|
||||
orchestrator._multi_search = multi_search
|
||||
|
||||
response = await orchestrator._step_searching()
|
||||
|
||||
assert response["success"] is False
|
||||
assert response["url_count"] == 0
|
||||
assert "no usable URLs" in response["error"]
|
||||
assert orchestrator._search_results == []
|
||||
|
||||
asyncio.run(run())
|
||||
|
||||
|
||||
def test_fetching_uses_actual_bytes_and_respects_remaining_source_budget() -> None:
|
||||
async def run() -> None:
|
||||
budget = HardBudgetConfig(max_sources=2, max_total_download_bytes=1_000)
|
||||
|
||||
Reference in New Issue
Block a user