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
moved test to test_proxy_server
Achintya Rajan169c1f0f217f
diff --git a/tests/test_litellm/proxy/test_proxy_server.py b/tests/test_litellm/proxy/test_proxy_server.pyindex 43e3e2ad0c9..21930d116d4 100644--- a/tests/test_litellm/proxy/test_proxy_server.py+++ b/tests/test_litellm/proxy/test_proxy_server.py@@ -126,6 +126,74 @@ async def test_initialize_scheduled_jobs_credentials(monkeypatch):assert len(mock_scheduler_calls) > 0+def test_update_config_fields_deep_merge_db_wins():+ from litellm.proxy.proxy_server import ProxyConfig++ proxy_config = ProxyConfig()++ current_config = {+ "router_settings": {+ "routing_mode": "cost_optimized",+ "model_group_alias": {+ # Existing alias with older model + different hidden flag+ "claude-sonnet-4": {+ "model": "claude-sonnet-4-20240219",+ "hidden": True,+ },+ # An extra alias that should remain untouched unless DB overrides it+ "legacy-sonnet": {+ "model": "claude-2.1",+ "hidden": True,+ },+ },+ }+ }++ db_param_value = {+ "model_group_alias": {+ # Conflict: DB should win (both 'model' and 'hidden')+ "claude-sonnet-4": {+ "model": "claude-sonnet-4-20250514",+ "hidden": False,+ },+ # New alias to be added by the merge+ "claude-sonnet-latest": {+ "model": "claude-sonnet-4-20250514",+ "hidden": True,+ },+ # Demonstrate that None values from DB are skipped (preserve existing)+ "legacy-sonnet": {+ "hidden": None # should not clobber current True+ },+ }+ }++ updated = proxy_config._update_config_fields(+ current_config=current_config,+ param_name="router_settings",+ db_param_value=db_param_value,+ )++ rs = updated["router_settings"]+ aliases = rs["model_group_alias"]++ # DB wins on conflicts (deep) for existing alias+ assert aliases["claude-sonnet-4"]["model"] == "claude-sonnet-4-20250514"+ assert aliases["claude-sonnet-4"]["hidden"] is False++ # New alias introduced by DB is present with its values+ assert "claude-sonnet-latest" in aliases+ assert aliases["claude-sonnet-latest"]["model"] == "claude-sonnet-4-20250514"+ assert aliases["claude-sonnet-latest"]["hidden"] is True++ # None in DB does not overwrite existing values+ assert aliases["legacy-sonnet"]["model"] == "claude-2.1"+ assert aliases["legacy-sonnet"]["hidden"] is True++ # Unrelated router_settings keys are preserved+ assert rs["routing_mode"] == "cost_optimized"++# Mock Prismaclass MockPrisma:def __init__(self, database_url=None, proxy_logging_obj=None, http_client=None):diff --git a/tests/test_litellm/proxy/test_proxy_utils.py b/tests/test_litellm/proxy/test_proxy_utils.pyindex 89e410af2c3..6997ac65275 100644--- a/tests/test_litellm/proxy/test_proxy_utils.py+++ b/tests/test_litellm/proxy/test_proxy_utils.py@@ -19,74 +19,6 @@ from unittest.mock import MagicMockfrom litellm.proxy.utils import get_custom_url-def test_update_config_fields_deep_merge_db_wins():- from litellm.proxy.proxy_server import ProxyConfig-- proxy_config = ProxyConfig()-- current_config = {- "router_settings": {- "routing_mode": "cost_optimized",- "model_group_alias": {- # Existing alias with older model + different hidden flag- "claude-sonnet-4": {- "model": "claude-sonnet-4-20240219",- "hidden": True,- },- # An extra alias that should remain untouched unless DB overrides it- "legacy-sonnet": {- "model": "claude-2.1",- "hidden": True,- },- },- }- }-- db_param_value = {- "model_group_alias": {- # Conflict: DB should win (both 'model' and 'hidden')- "claude-sonnet-4": {- "model": "claude-sonnet-4-20250514",- "hidden": False,- },- # New alias to be added by the merge- "claude-sonnet-latest": {- "model": "claude-sonnet-4-20250514",- "hidden": True,- },- # Demonstrate that None values from DB are skipped (preserve existing)- "legacy-sonnet": {- "hidden": None # should not clobber current True- },- }- }-- updated = proxy_config._update_config_fields(- current_config=current_config,- param_name="router_settings",- db_param_value=db_param_value,- )-- rs = updated["router_settings"]- aliases = rs["model_group_alias"]-- # DB wins on conflicts (deep) for existing alias- assert aliases["claude-sonnet-4"]["model"] == "claude-sonnet-4-20250514"- assert aliases["claude-sonnet-4"]["hidden"] is False-- # New alias introduced by DB is present with its values- assert "claude-sonnet-latest" in aliases- assert aliases["claude-sonnet-latest"]["model"] == "claude-sonnet-4-20250514"- assert aliases["claude-sonnet-latest"]["hidden"] is True-- # None in DB does not overwrite existing values- assert aliases["legacy-sonnet"]["model"] == "claude-2.1"- assert aliases["legacy-sonnet"]["hidden"] is True-- # Unrelated router_settings keys are preserved- assert rs["routing_mode"] == "cost_optimized"--def test_get_custom_url(monkeypatch):monkeypatch.setenv("SERVER_ROOT_PATH", "/litellm")custom_url = get_custom_url(request_base_url="http://0.0.0.0:4000", route="ui/")