Break up websocket component (#17003)
* Break up websocket component * Lint
This commit is contained in:
parent
9edf1e5151
commit
22a80cf733
21 changed files with 1041 additions and 1003 deletions
35
tests/components/websocket_api/conftest.py
Normal file
35
tests/components/websocket_api/conftest.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
"""Fixtures for websocket tests."""
|
||||
import pytest
|
||||
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components import websocket_api as wapi
|
||||
|
||||
from . import API_PASSWORD
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def websocket_client(hass, hass_ws_client):
|
||||
"""Create a websocket client."""
|
||||
return hass.loop.run_until_complete(hass_ws_client(hass))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def no_auth_websocket_client(hass, loop, aiohttp_client):
|
||||
"""Websocket connection that requires authentication."""
|
||||
assert loop.run_until_complete(
|
||||
async_setup_component(hass, 'websocket_api', {
|
||||
'http': {
|
||||
'api_password': API_PASSWORD
|
||||
}
|
||||
}))
|
||||
|
||||
client = loop.run_until_complete(aiohttp_client(hass.http.app))
|
||||
ws = loop.run_until_complete(client.ws_connect(wapi.URL))
|
||||
|
||||
auth_ok = loop.run_until_complete(ws.receive_json())
|
||||
assert auth_ok['type'] == wapi.TYPE_AUTH_REQUIRED
|
||||
|
||||
yield ws
|
||||
|
||||
if not ws.closed:
|
||||
loop.run_until_complete(ws.close())
|
Loading…
Add table
Add a link
Reference in a new issue