Skip to content

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]

test: cleanup old tests

Krrish Dholakia2c0520635d1a
diff --git a/tests/test_litellm/test_router.py b/tests/test_litellm/test_router.py
index 234941449b9..de7c3a74c21 100644
--- a/tests/test_litellm/test_router.py
+++ b/tests/test_litellm/test_router.py
@@ -896,148 +896,6 @@ async def test_router_ageneric_api_call_with_fallbacks_helper():
assert router.fail_calls["gpt-3.5-turbo"] == initial_fail_count + 1
-async def test_router_forward_client_headers_by_model_group():
- """
- Test that router.forward_client_headers_by_model_group returns the correct response
- """
- from unittest.mock import MagicMock, patch
-
- from litellm.types.router import ModelGroupSettings
-
- litellm.model_group_settings = ModelGroupSettings(
- forward_client_headers_to_llm_api=[
- "gpt-3.5-turbo-allow",
- "openai/*",
- "gpt-3.5-turbo-custom",
- ]
- )
-
- router = litellm.Router(
- model_list=[
- {
- "model_name": "gpt-3.5-turbo-allow",
- "litellm_params": {
- "model": "gpt-3.5-turbo",
- },
- },
- {
- "model_name": "gpt-3.5-turbo-disallow",
- "litellm_params": {
- "model": "gpt-3.5-turbo",
- },
- },
- {
- "model_name": "openai/*",
- "litellm_params": {
- "model": "openai/*",
- },
- },
- {
- "model_name": "openai/gpt-4o-mini",
- "litellm_params": {
- "model": "openai/gpt-4o-mini",
- },
- },
- ],
- model_group_alias={
- "gpt-3.5-turbo-custom": "gpt-3.5-turbo-disallow",
- },
- )
-
- ## Scenario 1: Direct model name
- with patch.object(
- litellm.main, "completion", return_value=MagicMock()
- ) as mock_completion:
- await router.acompletion(
- model="gpt-3.5-turbo-allow",
- messages=[{"role": "user", "content": "Hello, world!"}],
- mock_response="Hello, world!",
- secret_fields={"raw_headers": {"test": "test"}},
- )
-
- mock_completion.assert_called_once()
- print(mock_completion.call_args.kwargs["headers"])
-
- ## Scenario 2: Wildcard model name
- with patch.object(
- litellm.main, "completion", return_value=MagicMock()
- ) as mock_completion:
- await router.acompletion(
- model="openai/gpt-3.5-turbo",
- messages=[{"role": "user", "content": "Hello, world!"}],
- mock_response="Hello, world!",
- secret_fields={"raw_headers": {"test": "test"}},
- )
-
- mock_completion.assert_called_once()
- print(mock_completion.call_args.kwargs["headers"])
-
- ## Scenario 3: Not in model_group_settings
- with patch.object(
- litellm.main, "completion", return_value=MagicMock()
- ) as mock_completion:
- await router.acompletion(
- model="openai/gpt-4o-mini",
- messages=[{"role": "user", "content": "Hello, world!"}],
- mock_response="Hello, world!",
- secret_fields={"raw_headers": {"test": "test"}},
- )
-
- mock_completion.assert_called_once()
- assert mock_completion.call_args.kwargs.get("headers") is None
-
- ## Scenario 4: Model group alias
- with patch.object(
- litellm.main, "completion", return_value=MagicMock()
- ) as mock_completion:
- await router.acompletion(
- model="gpt-3.5-turbo-custom",
- messages=[{"role": "user", "content": "Hello, world!"}],
- mock_response="Hello, world!",
- secret_fields={"raw_headers": {"test": "test"}},
- )
-
- mock_completion.assert_called_once()
- print(mock_completion.call_args.kwargs["headers"])
-
-
-def test_router_apply_default_settings():
- """
- Test that Router.apply_default_settings() adds the expected default pre-call checks
- """
- router = litellm.Router(
- model_list=[
- {
- "model_name": "gpt-3.5-turbo",
- "litellm_params": {"model": "gpt-3.5-turbo"},
- }
- ],
- )
-
- # Apply default settings
- result = router.apply_default_settings()
-
- # Verify the method returns None
- assert result is None
-
- # Verify that the forward_client_headers_by_model_group pre-call check was added
- # Check if any callback is of the ForwardClientHeadersByModelGroupCheck type
- has_forward_headers_check = False
- for callback in litellm.callbacks:
- print(callback)
- print(f"callback.__class__: {callback.__class__}")
- if hasattr(
- callback, "__class__"
- ) and "ForwardClientSideHeadersByModelGroup" in str(callback.__class__):
- has_forward_headers_check = True
- break
-
- assert (
- has_forward_headers_check
- ), "Expected ForwardClientSideHeadersByModelGroup to be added to callbacks"
-
-
def test_router_get_model_access_groups_team_only_models():
"""
Test that Router.get_model_access_groups returns the correct response for team-only models