33from typing import AsyncContextManager , AsyncIterator , Optional , Any
44from unittest .mock import Mock
55
6- import websockets
6+ import websockets .legacy .client
7+ from hume .expression_measurement .stream .stream .socket_client import AsyncStreamSocketClient
78from pytest import MonkeyPatch
89
910from hume .client import AsyncHumeClient
10- from hume .empathic_voice .chat .socket_client import ChatWebsocketConnection
11- from hume .expression_measurement .stream .socket_client import StreamWebsocketConnection
11+ from hume .empathic_voice .chat .socket_client import AsyncChatSocketClient
1212
1313logger = logging .getLogger (__name__ )
1414
1515
1616# pylint: disable=unused-argument
17- def get_mock_connect (connection_string : str , assert_max_size : bool = False ) -> Any :
17+ def get_mock_connect (connection_string : str ) -> Any :
1818 def mock_connect (
1919 uri : str ,
2020 extra_headers : Optional [dict [str , str ]] = None ,
@@ -26,8 +26,6 @@ def mock_connect(
2626 assert isinstance (extra_headers , dict )
2727 assert extra_headers .get ("X-Fern-Language" ) == "Python"
2828 assert isinstance (extra_headers .get ("X-Fern-SDK-Version" ), str )
29- if assert_max_size :
30- assert max_size == 16777216
3129
3230 @asynccontextmanager
3331 async def mock_connection () -> AsyncIterator [Mock ]:
@@ -40,12 +38,12 @@ async def mock_connection() -> AsyncIterator[Mock]:
4038
4139async def test_chat_connect_basic (monkeypatch : MonkeyPatch ) -> None :
4240 hu = AsyncHumeClient (api_key = "0000-0000-0000-0000" )
43- monkeypatch .setattr (websockets , "connect" , get_mock_connect ("wss://api.hume.ai/v0/evi/chat" , assert_max_size = True ))
41+ monkeypatch .setattr (websockets . legacy . client , "connect" , get_mock_connect ("wss://api.hume.ai/v0/evi/chat" ))
4442 async with hu .empathic_voice .chat .connect () as socket :
45- assert isinstance (socket , ChatWebsocketConnection )
43+ assert isinstance (socket , AsyncChatSocketClient )
4644
4745async def test_stream_models_connect_basic (monkeypatch : MonkeyPatch ) -> None :
4846 hu = AsyncHumeClient (api_key = "0000-0000-0000-0000" )
49- monkeypatch .setattr (websockets , "connect" , get_mock_connect ("wss://api.hume.ai/v0/stream/models" ))
47+ monkeypatch .setattr (websockets . legacy . client , "connect" , get_mock_connect ("wss://api.hume.ai/v0/stream/models" ))
5048 async with hu .expression_measurement .stream .connect () as socket :
51- assert isinstance (socket , StreamWebsocketConnection )
49+ assert isinstance (socket , AsyncStreamSocketClient )
0 commit comments