From c55c292135756e222eb86f053d2d1b93cdb1670b Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Fri, 12 Jun 2026 17:01:23 -0700 Subject: [PATCH] test: adapt picked tests to stable/1.84.x fixture surface Three test-only adaptations required by the picks, none touching production code: restore the AsyncMock import that the upstream test_proxy_cli.py carries; drop three patch() entries targeting seed_request_identity, a helper that does not exist on this line; and re-graft the #30160 test block verbatim from the upstream hunk so the @patch decorators are included --- .../proxy/auth/test_auth_exception_handler.py | 9 --------- .../test_anthropic_passthrough_logging_handler.py | 2 ++ tests/test_litellm/proxy/test_proxy_cli.py | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/test_litellm/proxy/auth/test_auth_exception_handler.py b/tests/test_litellm/proxy/auth/test_auth_exception_handler.py index 9228cffa9a2..01fd43ee032 100644 --- a/tests/test_litellm/proxy/auth/test_auth_exception_handler.py +++ b/tests/test_litellm/proxy/auth/test_auth_exception_handler.py @@ -144,9 +144,6 @@ async def test_handle_authentication_error_db_infra_error_returns_503(db_error): new_callable=AsyncMock, return_value=None, ), - patch( - "litellm.proxy.auth.auth_exception_handler.seed_request_identity", - ), patch( "litellm.proxy.proxy_server.general_settings", {"allow_requests_on_db_unavailable": False}, @@ -201,9 +198,6 @@ async def test_handle_authentication_error_prisma_engine_teardown_returns_503(): new_callable=AsyncMock, return_value=None, ), - patch( - "litellm.proxy.auth.auth_exception_handler.seed_request_identity", - ), patch( "litellm.proxy.proxy_server.general_settings", {"allow_requests_on_db_unavailable": False}, @@ -251,9 +245,6 @@ async def test_handle_authentication_error_genuine_auth_failure_stays_401(auth_e new_callable=AsyncMock, return_value=None, ), - patch( - "litellm.proxy.auth.auth_exception_handler.seed_request_identity", - ), patch( "litellm.proxy.proxy_server.general_settings", {"allow_requests_on_db_unavailable": False}, diff --git a/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_anthropic_passthrough_logging_handler.py b/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_anthropic_passthrough_logging_handler.py index 8a9da81005f..7a9f73b70f3 100644 --- a/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_anthropic_passthrough_logging_handler.py +++ b/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_anthropic_passthrough_logging_handler.py @@ -321,6 +321,7 @@ class TestAzureAnthropicCostCalculation: assert call_kwargs["model"] == "azure_ai/claude-sonnet-4-5_gb_20250929" assert call_kwargs["custom_llm_provider"] == "azure_ai" + @patch("litellm.completion_cost") def test_cost_calculation_resolves_unknown_model_from_litellm_params( self, mock_completion_cost ): @@ -583,6 +584,7 @@ class TestAzureAnthropicCostCalculation: == "claude-3-5-haiku-20241022" ) + class TestAnthropicBatchPassthroughCostTracking: """Test cases for Anthropic batch passthrough cost tracking functionality""" diff --git a/tests/test_litellm/proxy/test_proxy_cli.py b/tests/test_litellm/proxy/test_proxy_cli.py index e022ec88327..8723273b941 100644 --- a/tests/test_litellm/proxy/test_proxy_cli.py +++ b/tests/test_litellm/proxy/test_proxy_cli.py @@ -1,6 +1,6 @@ import os import sys -from unittest.mock import MagicMock, patch +from unittest.mock import AsyncMock, MagicMock, patch import fastapi import pytest