diff --git a/backend/tests/AGENTS.md b/backend/tests/AGENTS.md index 7c8c6b9e96..02653e71ae 100644 --- a/backend/tests/AGENTS.md +++ b/backend/tests/AGENTS.md @@ -1,5 +1,9 @@ # Backend Tests +`test_image_result_url_safety.py` drives GroundRoute through `ainvoke` and an +offline HTTPX transport. Patch only the provider's `httpx` reference; preserve +the shared client and exercise real configuration resolution and URL screening. + `test_client_upload_snapshot.py` keeps upload publication and conversion on the same private capture. Cover source edits/removal, both conversion branches, same-file rejection, metadata and cleanup; retain sandbox symlink defenses. diff --git a/backend/tests/test_image_result_url_safety.py b/backend/tests/test_image_result_url_safety.py index 8522e9a51d..83308af8cb 100644 --- a/backend/tests/test_image_result_url_safety.py +++ b/backend/tests/test_image_result_url_safety.py @@ -95,7 +95,17 @@ def _stub_serply(module, url): def _stub_groundroute(module, url): data = {"results": [{"title": "t", "url": url, "snippet": "c"}]} - return [patch.object(module, "_get_api_key", return_value="k"), patch.object(module, "_post_search", return_value=data)], _sync(module.web_search_tool) + config = SimpleNamespace(get_tool_config=lambda _: SimpleNamespace(model_extra={"api_key": "synthetic-test-key"})) + transport = httpx.MockTransport(lambda request: httpx.Response(200, json=data)) + real_client = httpx.AsyncClient + return [ + patch.object(module, "get_app_config", return_value=config), + patch.object( + module, + "httpx", + SimpleNamespace(AsyncClient=lambda **kwargs: real_client(transport=transport, **kwargs), HTTPStatusError=httpx.HTTPStatusError), + ), + ], _async(module.web_search_tool) def _stub_sofya(module, url):