The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test: fix stale completion response fixtures
Yuneng Jiang1f7c4d678441
diff --git a/tests/llm_translation/test_azure_o_series.py b/tests/llm_translation/test_azure_o_series.pyindex 1a2d672af71..ce7e614cbe2 100644--- a/tests/llm_translation/test_azure_o_series.py+++ b/tests/llm_translation/test_azure_o_series.py@@ -159,15 +159,23 @@ def test_azure_o_series_routing():def test_openai_o_series_max_retries_0(mock_get_openai_client):import litellm+ mock_get_openai_client.return_value.chat.completions.with_raw_response.create.return_value.headers = {}+ mock_get_openai_client.return_value.chat.completions.with_raw_response.create.return_value.parse.return_value = (+ ModelResponse(choices=[{"message": {"role": "assistant", "content": "Hello"}}])+ )litellm.set_verbose = Trueresponse = litellm.completion(model="azure/o1-preview",messages=[{"role": "user", "content": "hi"}],max_retries=0,+ api_key="fake-key",+ api_base="https://fake-azure.openai.azure.com",+ api_version="2024-10-21",)mock_get_openai_client.assert_called_once()assert mock_get_openai_client.call_args.kwargs["max_retries"] == 0+ assert response.choices[0].message.content == "Hello"@pytest.mark.asynciodiff --git a/tests/llm_translation/test_azure_openai.py b/tests/llm_translation/test_azure_openai.pyindex 0fa72b45ed8..e6528e77749 100644--- a/tests/llm_translation/test_azure_openai.py+++ b/tests/llm_translation/test_azure_openai.py@@ -335,6 +335,10 @@ def test_azure_gpt_4o_with_tool_call_and_response_format(api_version):]with patch.object(client.chat.completions.with_raw_response, "create") as mock_post:+ mock_post.return_value.headers = {}+ mock_post.return_value.parse.return_value = litellm.ModelResponse(+ choices=[{"message": {"role": "assistant", "content": InvestigationOutput().model_dump_json()}}]+ )response = litellm.completion(model="azure/gpt-4.1-mini",messages=[@@ -362,6 +366,7 @@ def test_azure_gpt_4o_with_tool_call_and_response_format(api_version):assert "response_format" in mock_post.call_args.kwargselse:assert "response_format" not in mock_post.call_args.kwargs+ assert response.choices[0].message.content == InvestigationOutput().model_dump_json()def test_map_openai_params():diff --git a/tests/llm_translation/test_openai.py b/tests/llm_translation/test_openai.pyindex 2b9abdec5d0..af4ba85d58e 100644--- a/tests/llm_translation/test_openai.py+++ b/tests/llm_translation/test_openai.py@@ -292,15 +292,21 @@ class TestOpenAIChatCompletion(BaseLLMChatTest):def test_openai_max_retries_0(mock_get_openai_client):import litellm+ mock_get_openai_client.return_value.chat.completions.with_raw_response.create.return_value.headers = {}+ mock_get_openai_client.return_value.chat.completions.with_raw_response.create.return_value.parse.return_value = (+ ModelResponse(choices=[{"message": {"role": "assistant", "content": "Hello"}}])+ )litellm.set_verbose = Trueresponse = litellm.completion(model="gpt-4o-mini",messages=[{"role": "user", "content": "hi"}],max_retries=0,+ api_key="fake-key",)mock_get_openai_client.assert_called_once()assert mock_get_openai_client.call_args.kwargs["max_retries"] == 0+ assert response.choices[0].message.content == "Hello"@patch("litellm.main.openai_chat_completions._get_openai_client")diff --git a/tests/local_testing/test_completion.py b/tests/local_testing/test_completion.pyindex f8f23ea015a..43ed57f63af 100644--- a/tests/local_testing/test_completion.py+++ b/tests/local_testing/test_completion.py@@ -3999,10 +3999,14 @@ def test_completion_novita_ai():openai_client = OpenAI(api_key="fake-key")with patch.object(- openai_client.chat.completions, "create", new=MagicMock()+ openai_client.chat.completions.with_raw_response, "create") as mock_call:+ mock_call.return_value.headers = {}+ mock_call.return_value.parse.return_value = litellm.ModelResponse(+ choices=[{"message": {"role": "assistant", "content": "Hello"}}]+ )try:- completion(+ response = completion(model="novita/meta-llama/llama-3.3-70b-instruct",messages=messages,client=openai_client,@@ -4010,6 +4014,7 @@ def test_completion_novita_ai():)mock_call.assert_called_once()+ assert response.choices[0].message.content == "Hello"# Verify model is passed correctlyassert (