test(api): cover remote image URL rejection

This commit is contained in:
Xubin Ren
2026-04-16 21:02:33 +08:00
committed by Xubin Ren
parent 54b48a7431
commit 7ce8f247a0
+26
View File
@@ -316,6 +316,32 @@ async def test_multimodal_content_extracts_text(aiohttp_client, mock_agent) -> N
assert len(call_kwargs.get("media") or []) >= 0 # base64 images saved to disk
@pytest.mark.skipif(not HAS_AIOHTTP, reason="aiohttp not installed")
@pytest.mark.asyncio
async def test_multimodal_remote_image_url_returns_400(aiohttp_client, mock_agent) -> None:
app = create_app(mock_agent, model_name="m")
client = await aiohttp_client(app)
resp = await client.post(
"/v1/chat/completions",
json={
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "describe this"},
{"type": "image_url", "image_url": {"url": "https://example.com/image.png"}},
],
}
]
},
)
assert resp.status == 400
body = await resp.json()
assert "remote image urls are not supported" in body["error"]["message"].lower()
mock_agent.process_direct.assert_not_called()
@pytest.mark.skipif(not HAS_AIOHTTP, reason="aiohttp not installed")
@pytest.mark.asyncio
async def test_empty_response_retry_then_success(aiohttp_client) -> None: