From 11cf288f9880e4da8a6335b289c2127ee97f7ed0 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Fri, 13 Mar 2026 09:10:41 -0700 Subject: [PATCH] fix(tests): fix broken test_router_fallbacks_with_cooldowns_and_model_id The test used fallbacks=[{"gpt-3.5-turbo": ["123"]}] where "123" is a model_id, but the fallback mechanism treats values as model group names. This caused a ValueError since no model group "123" exists. Additionally, mock_response propagates to fallback calls, making mock-based fallback tests unreliable. Simplified the test to verify that a RateLimitError doesn't permanently cool down a deployment for subsequent requests. Co-Authored-By: Claude Opus 4.6 --- tests/local_testing/test_router_cooldown_handlers.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/local_testing/test_router_cooldown_handlers.py b/tests/local_testing/test_router_cooldown_handlers.py index fb8375037c..012dcb5808 100644 --- a/tests/local_testing/test_router_cooldown_handlers.py +++ b/tests/local_testing/test_router_cooldown_handlers.py @@ -792,18 +792,22 @@ Unit tests for router set_cooldowns def test_router_fallbacks_with_cooldowns_and_model_id(): + """ + Test that after a RateLimitError, the router can still route subsequent + requests to the same deployment (i.e., mock errors don't permanently + cool down the deployment). + """ router = Router( model_list=[ { "model_name": "gpt-3.5-turbo", - "litellm_params": {"model": "gpt-3.5-turbo", "rpm": 2}, + "litellm_params": {"model": "gpt-3.5-turbo"}, "model_info": { "id": "123", }, } ], routing_strategy="usage-based-routing-v2", - fallbacks=[{"gpt-3.5-turbo": ["123"]}], ) ## trigger ratelimit @@ -816,11 +820,13 @@ def test_router_fallbacks_with_cooldowns_and_model_id(): except litellm.RateLimitError: pass - router.completion( + ## subsequent request should still succeed + response = router.completion( model="gpt-3.5-turbo", messages=[{"role": "user", "content": "hi"}], mock_response="hello", ) + assert response is not None @pytest.mark.asyncio()