From 7ce8f247a0fadda56fbcc22cc15e22aec904f72d Mon Sep 17 00:00:00 2001 From: Xubin Ren Date: Thu, 16 Apr 2026 12:58:20 +0000 Subject: [PATCH] test(api): cover remote image URL rejection --- tests/test_openai_api.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_openai_api.py b/tests/test_openai_api.py index a6d019da..50607de4 100644 --- a/tests/test_openai_api.py +++ b/tests/test_openai_api.py @@ -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: