Add WebSocket API Foundation for zwave_js (#45151)

This commit is contained in:
Charles Garwood 2021-01-15 09:17:40 -05:00 committed by GitHub
parent 071c8cc67d
commit 9dbf14188a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 91 additions and 1 deletions

View file

@ -5,6 +5,7 @@ from unittest.mock import DEFAULT, patch
import pytest
from zwave_js_server.model.driver import Driver
from zwave_js_server.model.node import Node
from zwave_js_server.version import VersionInfo
from homeassistant.helpers.device_registry import (
async_get_registry as async_get_device_registry,
@ -25,6 +26,17 @@ def controller_state_fixture():
return json.loads(load_fixture("zwave_js/controller_state.json"))
@pytest.fixture(name="version_state", scope="session")
def version_state_fixture():
"""Load the version state fixture data."""
return {
"type": "version",
"driverVersion": "6.0.0-beta.0",
"serverVersion": "1.0.0",
"homeId": 1234567890,
}
@pytest.fixture(name="multisensor_6_state", scope="session")
def multisensor_6_state_fixture():
"""Load the multisensor 6 node state fixture data."""
@ -50,13 +62,17 @@ def bulb_6_multi_color_state_fixture():
@pytest.fixture(name="client")
def mock_client_fixture(controller_state):
def mock_client_fixture(controller_state, version_state):
"""Mock a client."""
with patch(
"homeassistant.components.zwave_js.ZwaveClient", autospec=True
) as client_class:
driver = Driver(client_class.return_value, controller_state)
version = VersionInfo.from_message(version_state)
client_class.return_value.driver = driver
client_class.return_value.version = version
client_class.return_value.ws_server_url = "ws://test:3000/zjs"
client_class.return_value.state = "connected"
yield client_class.return_value