forked from massive-com/client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_ws.py
More file actions
28 lines (21 loc) · 792 Bytes
/
base_ws.py
File metadata and controls
28 lines (21 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import unittest
import asyncio
from mock_server import run_mock_server
from typing import List
from polygon.websocket import WebSocketMessage
unittest.util._MAX_LENGTH = 30000 # type: ignore
# https://docs.python.org/3/library/unittest.html#unittest.IsolatedAsyncioTestCase
class BaseTest(unittest.IsolatedAsyncioTestCase):
expected: List[WebSocketMessage] = []
count = 0
def expectProcessor(self, msg):
self.assertEqual(msg, self.expected[self.count])
self.count += 1
def expectResponse(self, msg):
self.expected.append(msg)
async def asyncSetUp(self):
self.maxDiff = None
loop = asyncio.get_event_loop()
self.task = loop.create_task(run_mock_server())
async def asyncTearDown(self):
self.task.cancel()