def test_subscribe_channels(self): client = BcexClient( [Symbol.ETHBTC, Symbol.ALGOUSD], channels=[Channel.HEARTBEAT, Channel.SYMBOLS], api_secret="my_api_key", ) client._public_subscription = Mock() client._private_subscription = Mock() client._subscribe_channels() assert client._public_subscription.call_count == 1 assert client._private_subscription.call_count == 1 client._api_secret = None client._subscribe_channels() assert client._public_subscription.call_count == 2 assert client._private_subscription.call_count == 1
def test_connect(self, mock_webs, mock_threading): ws_mock = Mock() thread_mock = Mock() thread_mock.start = Mock() thread_mock.daemon = False mock_webs.WebSocketApp = Mock(return_value=ws_mock) mock_threading.Thread = Mock(return_value=thread_mock) client = BcexClient(symbols=["BTC-USD"]) client._subscribe_channels = Mock() client._wait_for_ws_connect = Mock() client.connect() assert mock_webs.WebSocketApp.call_count == 1 assert mock_threading.Thread.call_count == 1 assert client.wst == thread_mock assert client.wst.daemon is True assert client.wst.start.call_count == 1 assert client._wait_for_ws_connect.call_count == 1 assert client._subscribe_channels.call_count == 1