test(test_lowest_latency_routing.py): use mock responses

This commit is contained in:
Krrish Dholakia 2024-06-20 21:05:23 -07:00
parent e96326a211
commit cd73ea245a

View file

@ -1,22 +1,29 @@
#### What this tests #### #### What this tests ####
# This tests the router's ability to pick deployment with lowest latency # This tests the router's ability to pick deployment with lowest latency
import sys, os, asyncio, time, random import asyncio
from datetime import datetime, timedelta import os
import random
import sys
import time
import traceback import traceback
from datetime import datetime, timedelta
from dotenv import load_dotenv from dotenv import load_dotenv
load_dotenv() load_dotenv()
import os, copy import copy
import os
sys.path.insert( sys.path.insert(
0, os.path.abspath("../..") 0, os.path.abspath("../..")
) # Adds the parent directory to the system path ) # Adds the parent directory to the system path
import pytest import pytest
from litellm import Router
from litellm.router_strategy.lowest_latency import LowestLatencyLoggingHandler
from litellm.caching import DualCache
import litellm import litellm
from litellm import Router
from litellm.caching import DualCache
from litellm.router_strategy.lowest_latency import LowestLatencyLoggingHandler
### UNIT TESTS FOR LATENCY ROUTING ### ### UNIT TESTS FOR LATENCY ROUTING ###
@ -522,6 +529,7 @@ async def test_router_completion_streaming():
"api_key": "os.environ/AZURE_FRANCE_API_KEY", "api_key": "os.environ/AZURE_FRANCE_API_KEY",
"api_base": "https://openai-france-1234.openai.azure.com", "api_base": "https://openai-france-1234.openai.azure.com",
"rpm": 1440, "rpm": 1440,
"mock_response": "Hello world",
}, },
"model_info": {"id": 1}, "model_info": {"id": 1},
}, },
@ -532,6 +540,7 @@ async def test_router_completion_streaming():
"api_key": "os.environ/AZURE_EUROPE_API_KEY", "api_key": "os.environ/AZURE_EUROPE_API_KEY",
"api_base": "https://my-endpoint-europe-berri-992.openai.azure.com", "api_base": "https://my-endpoint-europe-berri-992.openai.azure.com",
"rpm": 6, "rpm": 6,
"mock_response": "Hello world",
}, },
"model_info": {"id": 2}, "model_info": {"id": 2},
}, },