Fix websocket api reaching queue (#7590)

* Fix websocket api reaching queue

* Fix outside task message sending

* Fix Py34 tests
This commit is contained in:
Paulus Schoutsen 2017-05-15 00:10:06 -07:00 committed by GitHub
parent 6d245c43fc
commit 36d7fe72eb
2 changed files with 79 additions and 38 deletions

View file

@ -50,6 +50,13 @@ def no_auth_websocket_client(hass, loop, test_client):
loop.run_until_complete(ws.close())
@pytest.fixture
def mock_low_queue():
"""Mock a low queue."""
with patch.object(wapi, 'MAX_PENDING_MSG', 5):
yield
@asyncio.coroutine
def test_auth_via_msg(no_auth_websocket_client):
"""Test authenticating."""
@ -304,3 +311,15 @@ def test_ping(websocket_client):
msg = yield from websocket_client.receive_json()
assert msg['id'] == 5
assert msg['type'] == wapi.TYPE_PONG
@asyncio.coroutine
def test_pending_msg_overflow(hass, mock_low_queue, websocket_client):
"""Test get_panels command."""
for idx in range(10):
websocket_client.send_json({
'id': idx + 1,
'type': wapi.TYPE_PING,
})
msg = yield from websocket_client.receive()
assert msg.type == WSMsgType.close