forked from phoenix/litellm-mirror
mock_patch_acompletion in test_proxy_server.py
This commit is contained in:
parent
152b5c8ceb
commit
4dfadb0cf4
1 changed files with 22 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
import sys, os
|
||||
import traceback
|
||||
from unittest import mock
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
@ -36,6 +37,25 @@ token = "sk-1234"
|
|||
headers = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
|
||||
def mock_patch_acompletion():
|
||||
async def side_effect(*args, **kwargs):
|
||||
return {
|
||||
"choices": [
|
||||
{
|
||||
"message": {
|
||||
"content": "Whispers of the wind carry dreams to me.",
|
||||
"role": "assistant"
|
||||
}
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
return mock.patch(
|
||||
"litellm.proxy.proxy_server.llm_router.acompletion",
|
||||
side_effect=side_effect,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def client_no_auth():
|
||||
# Assuming litellm.proxy.proxy_server is an object
|
||||
|
@ -104,7 +124,8 @@ def test_chat_completion_azure(client_no_auth):
|
|||
# test_chat_completion_azure()
|
||||
|
||||
|
||||
def test_openai_deployments_model_chat_completions_azure(client_no_auth):
|
||||
@mock_patch_acompletion()
|
||||
def test_openai_deployments_model_chat_completions_azure(_mock_acompletion, client_no_auth):
|
||||
global headers
|
||||
try:
|
||||
# Your test data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue