mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(test) proxy - AuthError Exception mapping
This commit is contained in:
parent
33afbd6ff5
commit
4413ef6dd2
2 changed files with 33 additions and 1 deletions
|
@ -47,6 +47,8 @@ def test_chat_completion_exception(client):
|
|||
|
||||
except Exception as e:
|
||||
pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}")
|
||||
|
||||
# raise openai.AuthenticationError
|
||||
def test_chat_completion_exception_azure(client):
|
||||
try:
|
||||
# Your test data
|
||||
|
@ -72,6 +74,30 @@ def test_chat_completion_exception_azure(client):
|
|||
pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}")
|
||||
|
||||
|
||||
# raise openai.AuthenticationError
|
||||
def test_embedding_auth_exception_azure(client):
|
||||
try:
|
||||
# Your test data
|
||||
test_data = {
|
||||
"model": "azure-embedding",
|
||||
"input": ["hi"]
|
||||
}
|
||||
|
||||
response = client.post("/embeddings", json=test_data)
|
||||
print("Response from proxy=", response)
|
||||
|
||||
# make an openai client to call _make_status_error_from_response
|
||||
openai_client = openai.OpenAI(api_key="anything")
|
||||
openai_exception = openai_client._make_status_error_from_response(response=response)
|
||||
print("Exception raised=", openai_exception)
|
||||
assert isinstance(openai_exception, openai.AuthenticationError)
|
||||
|
||||
except Exception as e:
|
||||
pytest.fail(f"LiteLLM Proxy test failed. Exception {str(e)}")
|
||||
|
||||
|
||||
|
||||
|
||||
# raise openai.BadRequestError
|
||||
# chat/completions openai
|
||||
def test_exception_openai_bad_model(client):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue