diff --git a/tests/proxy_unit_tests/test_user_api_key_auth.py b/tests/proxy_unit_tests/test_user_api_key_auth.py index 2d7de01ec0a..1e3ec1e3019 100644 --- a/tests/proxy_unit_tests/test_user_api_key_auth.py +++ b/tests/proxy_unit_tests/test_user_api_key_auth.py @@ -827,6 +827,10 @@ async def test_user_api_key_auth_websocket(): mock_websocket = MagicMock(spec=WebSocket) mock_websocket.query_params = {"model": "some_model"} mock_websocket.headers = {"authorization": "Bearer some_api_key"} + # Mock the scope attribute that user_api_key_auth_websocket accesses + mock_websocket.scope = {"headers": [(b"authorization", b"Bearer some_api_key")]} + # Mock the url attribute + mock_websocket.url = URL(url="/ws") # Mock the return value of `user_api_key_auth` when it's called within the `user_api_key_auth_websocket` function with patch( diff --git a/tests/test_litellm/llms/openai/realtime/test_openai_realtime_handler.py b/tests/test_litellm/llms/openai/realtime/test_openai_realtime_handler.py index bd973692c1e..3a446a2048e 100644 --- a/tests/test_litellm/llms/openai/realtime/test_openai_realtime_handler.py +++ b/tests/test_litellm/llms/openai/realtime/test_openai_realtime_handler.py @@ -168,6 +168,7 @@ async def test_async_realtime_url_contains_model(): async def __aexit__(self, exc_type, exc, tb): return None + shared_context = get_shared_realtime_ssl_context() with patch("websockets.connect", return_value=DummyAsyncContextManager(mock_backend_ws)) as mock_ws_connect, \ patch("litellm.llms.openai.realtime.handler.RealTimeStreaming") as mock_realtime_streaming: