From 428d0c0b4674ccc266aa680d5520f45375866a2a Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Sun, 2 Aug 2026 22:18:15 +0200 Subject: [PATCH] test: cover provider status aggregation --- tests/test_search_service_components.py | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/test_search_service_components.py b/tests/test_search_service_components.py index 6803396..b36bfca 100644 --- a/tests/test_search_service_components.py +++ b/tests/test_search_service_components.py @@ -555,6 +555,53 @@ async def test_search_orchestrator_force_search_refreshes_selected_caches(): ].assert_called_once_with() +@pytest.mark.asyncio +async def test_search_orchestrator_preserves_provider_status_metadata(): + orchestrator, _dependencies = _build_search_orchestrator() + orchestrator.provider_runner = _StaticSearchRunner( + { + "civarchive": None, + "source_errors": { + "civarchive": "CivArchive search failed: HTTP 522" + }, + "source_status": { + "civarchive": { + "state": "unavailable", + "code": "provider_unavailable", + "retryable": True, + "http_status": 522, + "message": ( + "CivArchive may be overloaded or temporarily unavailable. " + "Please try again." + ), + } + }, + }, + False, + ) + request = SimpleNamespace( + json=AsyncMock( + return_value={ + "filename": "model.safetensors", + "sources": ["civarchive"], + "progress_id": "provider-status-search", + } + ) + ) + + response = await orchestrator.search_sources(request) + + assert response.status == 200 + assert response.payload["found"] is False + assert response.payload["source_errors"] == { + "civarchive": "CivArchive search failed: HTTP 522" + } + assert response.payload["source_status"]["civarchive"]["code"] == ( + "provider_unavailable" + ) + assert response.payload["source_status"]["civarchive"]["retryable"] is True + + @pytest.mark.asyncio async def test_search_orchestrator_returns_cancelled_response(): orchestrator, dependencies = _build_search_orchestrator()