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]

Fixing tests

yuneng-jiangef7261d0eb4d
diff --git a/tests/proxy_unit_tests/test_proxy_server.py b/tests/proxy_unit_tests/test_proxy_server.py
index 839d09b52d7..d864a0d986a 100644
--- a/tests/proxy_unit_tests/test_proxy_server.py
+++ b/tests/proxy_unit_tests/test_proxy_server.py
@@ -1117,7 +1117,10 @@ async def test_create_team_member_add(prisma_client, new_member_method):
) as mock_litellm_usertable, patch(
"litellm.proxy.auth.auth_checks._get_team_object_from_user_api_key_cache",
new=AsyncMock(return_value=team_obj),
- ) as mock_team_obj:
+ ) as mock_team_obj, patch(
+ "litellm.proxy.proxy_server.prisma_client.get_data",
+ new=AsyncMock(return_value=[]),
+ ) as mock_get_data:
mock_client = AsyncMock(
return_value=LiteLLM_UserTable(
@@ -1126,6 +1129,10 @@ async def test_create_team_member_add(prisma_client, new_member_method):
)
mock_litellm_usertable.upsert = mock_client
mock_litellm_usertable.find_many = AsyncMock(return_value=None)
+ # Mock find_first for user_email validation (returns None for new users)
+ mock_litellm_usertable.find_first = AsyncMock(return_value=None)
+ # Mock find_unique for user_id validation (returns None for new users)
+ mock_litellm_usertable.find_unique = AsyncMock(return_value=None)
team_mock_client = AsyncMock()
original_val = getattr(
litellm.proxy.proxy_server.prisma_client.db, "litellm_teamtable"
@@ -1299,7 +1306,10 @@ async def test_create_team_member_add_team_admin(
) as mock_litellm_usertable, patch(
"litellm.proxy.auth.auth_checks._get_team_object_from_user_api_key_cache",
new=AsyncMock(return_value=team_obj),
- ) as mock_team_obj:
+ ) as mock_team_obj, patch(
+ "litellm.proxy.proxy_server.prisma_client.get_data",
+ new=AsyncMock(return_value=[]),
+ ) as mock_get_data:
mock_client = AsyncMock(
return_value=LiteLLM_UserTable(
user_id="1234", max_budget=100, user_email="1234"
@@ -1307,6 +1317,10 @@ async def test_create_team_member_add_team_admin(
)
mock_litellm_usertable.upsert = mock_client
mock_litellm_usertable.find_many = AsyncMock(return_value=None)
+ # Mock find_first for user_email validation (returns None for new users)
+ mock_litellm_usertable.find_first = AsyncMock(return_value=None)
+ # Mock find_unique for user_id validation (returns None for new users)
+ mock_litellm_usertable.find_unique = AsyncMock(return_value=None)
team_mock_client = AsyncMock()
original_val = getattr(