mock_patch_acompletion in test_proxy_server.py

This commit is contained in:
Marc Abramowitz 2024-05-02 12:24:49 -07:00
parent 152b5c8ceb
commit 4dfadb0cf4

View file

@ -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