Initial WS support (#2439)

* Initial WS support

* test

* Update frontend to fc7c4af2

* Fix issue with closing states

* log error

* make data optional

* limit stopping states

* Move wrappers to HomeAssistantWebSocket

* use info

* Use call_soon

* Use lookuptable for WS commands

* Fix tests
This commit is contained in:
Joakim Sørensen
2021-02-19 11:57:31 +01:00
committed by GitHub
parent c342231052
commit b31ecfefcd
46 changed files with 463 additions and 220 deletions

View File

@@ -6,6 +6,7 @@ from uuid import uuid4
from aiohttp import web
from aiohttp.test_utils import TestClient
from awesomeversion import AwesomeVersion
import pytest
from supervisor.api import RestAPI
@@ -20,6 +21,12 @@ from tests.common import exists_fixture, load_fixture, load_json_fixture
# pylint: disable=redefined-outer-name, protected-access
async def mock_async_return_true() -> bool:
"""Mock methods to return True."""
return True
@pytest.fixture
def docker() -> DockerAPI:
"""Mock DockerAPI."""
@@ -148,6 +155,12 @@ async def coresys(loop, docker, network_manager, aiohttp_client) -> CoreSys:
coresys_obj.supervisor._connectivity = True
coresys_obj.host.network._connectivity = True
# WebSocket
coresys_obj.homeassistant.api.check_api_state = mock_async_return_true
coresys_obj.homeassistant._websocket._client = AsyncMock(
ha_version=AwesomeVersion("2021.2.4")
)
yield coresys_obj