fix(tests): adapt GroundRoute URL screening fixture to async transport (#7263)

This commit is contained in:
Willem Jiang 2026-10-22 11:29:39 +08:00 committed by GitHub
parent 7e1f814b2c
commit 0efd95568d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -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.

View File

@ -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):