Better handle large amounts of data being sent over WS (#23842)

* Better handle large amounts of data being sent over WS

* Lint
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-05-14 05:57:47 +02:00
1 parent b2a1204bc5
commit 45085dd97f
7 files changed
+59 -20

No files matched your search

@@ -0,0 +1,30 @@
"""Test WebSocket Connection class."""
from homeassistant.components import websocket_api
from homeassistant.components.websocket_api import const
async def test_send_big_result(hass, websocket_client):
"""Test sending big results over the WS."""
@websocket_api.websocket_command({
'type': 'big_result'
})
@websocket_api.async_response
async def send_big_result(hass, connection, msg):
await connection.send_big_result(
msg['id'], {'big': 'result'}
)
hass.components.websocket_api.async_register_command(
send_big_result
)
await websocket_client.send_json({
'id': 5,
'type': 'big_result',
})
msg = await websocket_client.receive_json()
assert msg['id'] == 5
assert msg['type'] == const.TYPE_RESULT
assert msg['success']
assert msg['result'] == {'big': 'result'}