更新
This commit is contained in:
@@ -20,7 +20,10 @@ from rpa_engine.douyin_im.session import DouyinImSession
|
||||
from rpa_engine.douyin_im.ws_client import DouyinImWsClient, _reconnect_delay
|
||||
|
||||
|
||||
TEST_WS_URL = "wss://frontier-im.douyin.com/ws/v2?token=test-token-value"
|
||||
TEST_WS_URL = (
|
||||
"wss://frontier-im.douyin.com/ws/v2?fpid=9&device_id=10001&"
|
||||
"token=test-token-value"
|
||||
)
|
||||
|
||||
|
||||
class _FakeWebSocket:
|
||||
@@ -108,6 +111,25 @@ class WebSocketScalingTests(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertFalse(client.connected)
|
||||
self.assertIsNone(client._connection)
|
||||
|
||||
async def test_browser_frontier_uses_text_heartbeat_and_filters_ack(self):
|
||||
client = self._make_client()
|
||||
client._running = True
|
||||
websocket = AsyncMock()
|
||||
|
||||
heartbeat = asyncio.create_task(client._run_browser_heartbeat(websocket))
|
||||
for _ in range(20):
|
||||
if websocket.send.await_count:
|
||||
break
|
||||
await asyncio.sleep(0)
|
||||
heartbeat.cancel()
|
||||
with self.assertRaises(asyncio.CancelledError):
|
||||
await heartbeat
|
||||
|
||||
websocket.send.assert_awaited_once_with("hi")
|
||||
with patch.object(ws_module, "parse_ws_payload") as parse:
|
||||
await client._dispatch("hi")
|
||||
parse.assert_not_called()
|
||||
|
||||
async def test_starting_500_clients_does_not_create_os_threads(self):
|
||||
parked = asyncio.Event()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user