From a82ecf54127b4f02437a6d5feac86e7fe4ae1811 Mon Sep 17 00:00:00 2001 From: Alexander Golec Date: Sun, 31 May 2020 22:13:42 -0400 Subject: [PATCH] Added tests for performing actions before calling login() --- tests/streaming_test.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/streaming_test.py b/tests/streaming_test.py index 8a7fd1f..8afb0d6 100644 --- a/tests/streaming_test.py +++ b/tests/streaming_test.py @@ -3061,3 +3061,13 @@ async def test_multiple_data_per_message(self, ws_connect): await self.client.handle_message() handler_1.assert_has_calls( [call(stream_item['data'][0]), call(stream_item['data'][1])]) + + @patch('tda.streaming.websockets.client.connect', autospec=AsyncMock()) + async def test_handle_message_without_login(self, ws_connect): + with self.assertRaisesRegex(ValueError, '.*Socket not open.*'): + await self.client.handle_message() + + @patch('tda.streaming.websockets.client.connect', autospec=AsyncMock()) + async def test_subscribe_without_login(self, ws_connect): + with self.assertRaisesRegex(ValueError, '.*Socket not open.*'): + await self.client.chart_equity_subs(['GOOG,MSFT'])