1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

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
2019-05-14 05:57:47 +02:00
committed by GitHub
parent b2a1204bc5
commit 45085dd97f
7 changed files with 59 additions and 20 deletions

View File

@@ -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'}