From be4a79710dbce675b7f5cf7e0ee489b5191ad11e Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Tue, 25 Aug 2026 23:43:11 -0700 Subject: [PATCH] test(azure-ai): match the exact route the provider is called on The fixture was matched by host alone, so it answered any method and path and the tests would have stayed green if the request went somewhere else. It now matches POST on the Foundry route, and asserts the route was called. Worth pinning on its own: the real path carries a /models prefix, which the first attempt at this got wrong, so the match now also holds the routing in place rather than only the retry. --- .../llms/custom_httpx/test_llm_http_handler.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_litellm/llms/custom_httpx/test_llm_http_handler.py b/tests/test_litellm/llms/custom_httpx/test_llm_http_handler.py index bbd014bff18..18d1aa949a8 100644 --- a/tests/test_litellm/llms/custom_httpx/test_llm_http_handler.py +++ b/tests/test_litellm/llms/custom_httpx/test_llm_http_handler.py @@ -2759,8 +2759,8 @@ def test_video_generation_with_input_reference_keeps_file_multipart(): assert result.status == "queued" -AZURE_AI_HOST = "myfoundry.services.ai.azure.com" -AZURE_AI_BASE = f"https://{AZURE_AI_HOST}" +AZURE_AI_BASE = "https://myfoundry.services.ai.azure.com" +AZURE_AI_CHAT_COMPLETIONS_URL = f"{AZURE_AI_BASE}/models/chat/completions" def _a_tool_with_an_unsupported_field() -> dict: return { @@ -2807,8 +2807,8 @@ def _rejection(message: str) -> httpx.Response: def _call_azure_ai(recorder: _RecordedAzureAI, **overrides): import respx - with respx.mock: - respx.route(host=AZURE_AI_HOST).mock(side_effect=recorder) + with respx.mock(assert_all_called=True) as router: + router.post(AZURE_AI_CHAT_COMPLETIONS_URL).mock(side_effect=recorder) return litellm.completion( model="azure_ai/grok-3", messages=[{"role": "user", "content": "hi"}], @@ -2894,8 +2894,8 @@ async def test_a_tool_field_the_provider_rejects_is_dropped_and_retried_on_the_a [_rejection(TOOL_LEVEL_REJECTION), httpx.Response(200, json=A_COMPLETION)] ) - with respx.mock: - respx.route(host=AZURE_AI_HOST).mock(side_effect=recorder) + with respx.mock(assert_all_called=True) as router: + router.post(AZURE_AI_CHAT_COMPLETIONS_URL).mock(side_effect=recorder) response = await litellm.acompletion( model="azure_ai/grok-3", messages=[{"role": "user", "content": "hi"}], @@ -2918,8 +2918,8 @@ async def test_a_provider_that_keeps_rejecting_is_not_retried_forever_on_the_asy recorder = _RecordedAzureAI([_rejection(TOOL_LEVEL_REJECTION)]) - with respx.mock: - respx.route(host=AZURE_AI_HOST).mock(side_effect=recorder) + with respx.mock(assert_all_called=True) as router: + router.post(AZURE_AI_CHAT_COMPLETIONS_URL).mock(side_effect=recorder) with pytest.raises(litellm.BadRequestError): await litellm.acompletion( model="azure_ai/grok-3",