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
test fix cli credentials
Ishaan Jaffbffe5bec7d50
diff --git a/tests/test_litellm/proxy/client/test_credentials.py b/tests/test_litellm/proxy/client/test_credentials.pyindex a6bfb287754..702872a5896 100644--- a/tests/test_litellm/proxy/client/test_credentials.py+++ b/tests/test_litellm/proxy/client/test_credentials.py@@ -62,7 +62,8 @@ def test_list_request(client, base_url, api_key):assert request.headers["Authorization"] == f"Bearer {api_key}"-def test_list_mock_response(client, requests_mock):+def test_list_mock_response(client):"""Test list with a mocked successful response"""mock_response = {"credentials": [@@ -79,17 +80,24 @@ def test_list_mock_response(client, requests_mock):]}- requests_mock.get(f"{client._base_url}/credentials", json=mock_response)+ responses.add(+ responses.GET,+ f"{client._base_url}/credentials",+ json=mock_response,+ status=200,+ )response = client.list()assert response == mock_response-def test_list_unauthorized_error(client, requests_mock):+def test_list_unauthorized_error(client):"""Test that list raises UnauthorizedError for 401 responses"""- requests_mock.get(+ responses.add(+ responses.GET,f"{client._base_url}/credentials",- status_code=401,+ status=401,json={"error": "Unauthorized"},)@@ -123,7 +131,8 @@ def test_create_request(client, base_url, api_key):}-def test_create_mock_response(client, requests_mock):+def test_create_mock_response(client):"""Test create with a mocked successful response"""mock_response = {"credential_name": "azure1",@@ -131,7 +140,12 @@ def test_create_mock_response(client, requests_mock):"status": "success",}- requests_mock.post(f"{client._base_url}/credentials", json=mock_response)+ responses.add(+ responses.POST,+ f"{client._base_url}/credentials",+ json=mock_response,+ status=200,+ )response = client.create(credential_name="azure1",@@ -144,11 +158,13 @@ def test_create_mock_response(client, requests_mock):assert response == mock_response-def test_create_unauthorized_error(client, requests_mock):+def test_create_unauthorized_error(client):"""Test that create raises UnauthorizedError for 401 responses"""- requests_mock.post(+ responses.add(+ responses.POST,f"{client._base_url}/credentials",- status_code=401,+ status=401,json={"error": "Unauthorized"},)@@ -170,21 +186,29 @@ def test_delete_request(client, base_url, api_key):assert request.headers["Authorization"] == f"Bearer {api_key}"-def test_delete_mock_response(client, requests_mock):+def test_delete_mock_response(client):"""Test delete with a mocked successful response"""mock_response = {"credential_name": "azure1", "status": "deleted"}- requests_mock.delete(f"{client._base_url}/credentials/azure1", json=mock_response)+ responses.add(+ responses.DELETE,+ f"{client._base_url}/credentials/azure1",+ json=mock_response,+ status=200,+ )response = client.delete(credential_name="azure1")assert response == mock_response-def test_delete_unauthorized_error(client, requests_mock):+def test_delete_unauthorized_error(client):"""Test that delete raises UnauthorizedError for 401 responses"""- requests_mock.delete(+ responses.add(+ responses.DELETE,f"{client._base_url}/credentials/azure1",- status_code=401,+ status=401,json={"error": "Unauthorized"},)@@ -202,7 +226,8 @@ def test_get_request(client, base_url, api_key):assert request.headers["Authorization"] == f"Bearer {api_key}"-def test_get_mock_response(client, requests_mock):+def test_get_mock_response(client):"""Test get with a mocked successful response"""mock_response = {"credential_name": "azure1",@@ -214,19 +239,24 @@ def test_get_mock_response(client, requests_mock):"status": "active",}- requests_mock.get(- f"{client._base_url}/credentials/by_name/azure1", json=mock_response+ responses.add(+ responses.GET,+ f"{client._base_url}/credentials/by_name/azure1",+ json=mock_response,+ status=200,)response = client.get(credential_name="azure1")assert response == mock_response-def test_get_unauthorized_error(client, requests_mock):+def test_get_unauthorized_error(client):"""Test that get raises UnauthorizedError for 401 responses"""- requests_mock.get(+ responses.add(+ responses.GET,f"{client._base_url}/credentials/by_name/azure1",- status_code=401,+ status=401,json={"error": "Unauthorized"},)diff --git a/tests/test_litellm/proxy/client/test_models.py b/tests/test_litellm/proxy/client/test_models.pyindex 1f991d3a1c0..970dba712a3 100644--- a/tests/test_litellm/proxy/client/test_models.py+++ b/tests/test_litellm/proxy/client/test_models.py@@ -23,6 +23,10 @@ def base_url():def api_key():return "test-api-key"+def requests_mock():+ return requests_mock+@pytest.fixturedef client(base_url, api_key):