From 4dfadb0cf4c3cf4c5de79bc8e8a81ac10c0ee245 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Thu, 2 May 2024 12:24:49 -0700 Subject: [PATCH] mock_patch_acompletion in test_proxy_server.py --- litellm/tests/test_proxy_server.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/litellm/tests/test_proxy_server.py b/litellm/tests/test_proxy_server.py index 3e301dbd0d..3c192ca228 100644 --- a/litellm/tests/test_proxy_server.py +++ b/litellm/tests/test_proxy_server.py @@ -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