mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
fix: add missing mock attributes in websocket and realtime tests (#16974)
- Add scope and url attributes to WebSocket mock in test_user_api_key_auth_websocket - Add shared_realtime_ssl_context initialization in realtime handler test
This commit is contained in:
parent
2a92e97d63
commit
ca2a27c377
2 changed files with 5 additions and 0 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue