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
handle failed db connections
Ishaan Jaff6e5d2b1ac77e
diff --git a/tests/proxy_unit_tests/test_auth_checks.py b/tests/proxy_unit_tests/test_auth_checks.pyindex 0eb1a387558..7695306c87c 100644--- a/tests/proxy_unit_tests/test_auth_checks.py+++ b/tests/proxy_unit_tests/test_auth_checks.py@@ -13,9 +13,6 @@ sys.path.insert() # Adds the parent directory to the system pathimport pytest, litellmimport httpx-from litellm.proxy.auth.auth_checks import (- _handle_failed_db_connection_for_get_key_object,-)from litellm.proxy._types import UserAPIKeyAuthfrom litellm.proxy.auth.auth_checks import get_end_user_objectfrom litellm.caching.caching import DualCache@@ -78,36 +75,6 @@ async def test_get_end_user_object(customer_spend, customer_budget):)-async def test_handle_failed_db_connection():- """- Test cases:- 1. When allow_requests_on_db_unavailable=True -> return UserAPIKeyAuth- 2. When allow_requests_on_db_unavailable=False -> raise original error- """- from litellm.proxy.proxy_server import general_settings, litellm_proxy_admin_name-- # Test case 1: allow_requests_on_db_unavailable=True- general_settings["allow_requests_on_db_unavailable"] = True- mock_error = httpx.ConnectError("Failed to connect to DB")-- result = await _handle_failed_db_connection_for_get_key_object(e=mock_error)-- assert isinstance(result, UserAPIKeyAuth)- assert result.key_name == "failed-to-connect-to-db"- assert result.token == "failed-to-connect-to-db"- assert result.user_id == litellm_proxy_admin_name-- # Test case 2: allow_requests_on_db_unavailable=False- general_settings["allow_requests_on_db_unavailable"] = False-- with pytest.raises(httpx.ConnectError) as exc_info:- await _handle_failed_db_connection_for_get_key_object(e=mock_error)- print("_handle_failed_db_connection_for_get_key_object got exception", exc_info)-- assert str(exc_info.value) == "Failed to connect to DB"--@pytest.mark.parametrize("model, expect_to_work",[