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 delete keys
Ishaan Jaff282ce1a859dd
diff --git a/tests/test_litellm/proxy/client/cli/test_keys_commands.py b/tests/test_litellm/proxy/client/cli/test_keys_commands.pyindex 1347a776b1b..d3e2d4ce7b6 100644--- a/tests/test_litellm/proxy/client/cli/test_keys_commands.py+++ b/tests/test_litellm/proxy/client/cli/test_keys_commands.py@@ -116,9 +116,36 @@ def test_keys_generate_error_handling(mock_keys_client, cli_runner):def test_keys_delete_error_handling(mock_keys_client, cli_runner):- mock_keys_client.return_value.delete.side_effect = Exception("API Error")+ import requests++ # Mock a connection error that would normally happen in CI+ mock_keys_client.return_value.delete.side_effect = requests.exceptions.ConnectionError(+ "Connection error"+ )result = cli_runner.invoke(cli, ["keys", "delete", "--keys", "abc123"])assert result.exit_code != 0# Check that the exception is properly propagatedassert result.exception is not None- assert "API Error" in str(result.exception)+ # The ConnectionError should propagate since it's not caught by HTTPError handler+ assert "Connection error" in str(result.exception)+++def test_keys_delete_http_error_handling(mock_keys_client, cli_runner):+ from unittest.mock import Mock++ import requests++ # Create a mock response object for HTTPError+ mock_response = Mock()+ mock_response.status_code = 400+ mock_response.json.return_value = {"error": "Bad request"}++ # Mock an HTTPError which should be caught by the delete command+ http_error = requests.exceptions.HTTPError("HTTP Error")+ http_error.response = mock_response+ mock_keys_client.return_value.delete.side_effect = http_error++ result = cli_runner.invoke(cli, ["keys", "delete", "--keys", "abc123"])+ assert result.exit_code != 0+ # HTTPError should be caught and converted to click.Abort+ assert isinstance(result.exception, SystemExit) # click.Abort raises SystemExit