mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 10:14:26 +00:00
(test) ensure exception raised when incorrect key passed
This commit is contained in:
parent
8ac03e492f
commit
525e01824a
1 changed files with 28 additions and 0 deletions
|
@ -170,6 +170,34 @@ def test_invalid_request_error(model):
|
|||
with pytest.raises(BadRequestError):
|
||||
completion(model=model, messages=messages, max_tokens="hello world")
|
||||
|
||||
|
||||
|
||||
def test_completion_azure_exception():
|
||||
try:
|
||||
import openai
|
||||
print("azure gpt-3.5 test\n\n")
|
||||
litellm.set_verbose=False
|
||||
## Test azure call
|
||||
old_azure_key = os.environ["AZURE_API_KEY"]
|
||||
os.environ["AZURE_API_KEY"] = ""
|
||||
response = completion(
|
||||
model="azure/chatgpt-v-2",
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": "hello"
|
||||
}
|
||||
],
|
||||
)
|
||||
print(f"response: {response}")
|
||||
print(response)
|
||||
except openai.APIConnectionError as e:
|
||||
os.environ["AZURE_API_KEY"] = old_azure_key
|
||||
print("good job got the correct error for azure when key not set")
|
||||
except Exception as e:
|
||||
pytest.fail(f"Error occurred: {e}")
|
||||
test_completion_azure_exception()
|
||||
|
||||
# test_invalid_request_error(model="command-nightly")
|
||||
# Test 3: Rate Limit Errors
|
||||
# def test_model_call(model):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue