Skip to content

Commit b1bf49f

Browse files
committed
Make test_load_router_config pass
by mocking the necessary things in the test. Now all the tests in `test_proxy_server.py` pass! 🎉 ```shell $ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py --disable-warnings ====================================== test session starts ====================================== platform darwin -- Python 3.12.3, pytest-7.4.4, pluggy-1.5.0 rootdir: /Users/abramowi/Code/OpenSource/litellm plugins: anyio-4.3.0, asyncio-0.23.6, mock-3.14.0 asyncio: mode=Mode.STRICT collected 12 items litellm/tests/test_proxy_server.py s..........s [100%] ========================== 10 passed, 2 skipped, 48 warnings in 10.70s ========================== ```
1 parent 2e9f4ff commit b1bf49f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

litellm/tests/test_proxy_server.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def fake_env_vars(monkeypatch):
116116
monkeypatch.setenv("AZURE_API_BASE", "http://fake-azure-api-base")
117117
monkeypatch.setenv("AZURE_OPENAI_API_KEY", "fake_azure_openai_api_key")
118118
monkeypatch.setenv("AZURE_SWEDEN_API_BASE", "http://fake-azure-sweden-api-base")
119+
monkeypatch.setenv("REDIS_HOST", "localhost")
119120

120121

121122
@pytest.fixture(scope="function")
@@ -505,7 +506,18 @@ def test_chat_completion_optional_params(mock_acompletion, client_no_auth):
505506
from litellm.proxy.proxy_server import ProxyConfig
506507

507508

508-
def test_load_router_config():
509+
@mock.patch("litellm.proxy.proxy_server.litellm.Cache")
510+
def test_load_router_config(mock_cache, fake_env_vars):
511+
mock_cache.return_value.cache.__dict__ = {"redis_client": None}
512+
mock_cache.return_value.supported_call_types = [
513+
"completion",
514+
"acompletion",
515+
"embedding",
516+
"aembedding",
517+
"atranscription",
518+
"transcription",
519+
]
520+
509521
try:
510522
import asyncio
511523

@@ -567,6 +579,10 @@ def test_load_router_config():
567579
litellm.disable_cache()
568580

569581
print("testing reading proxy config for cache with params")
582+
mock_cache.return_value.supported_call_types = [
583+
"embedding",
584+
"aembedding",
585+
]
570586
asyncio.run(
571587
proxy_config.load_config(
572588
router=None,

0 commit comments

Comments
 (0)