mirror of
https://github.com/home-assistant/core.git
synced 2026-11-30 01:33:12 -04:00
Guard zwave_js missing nodes in websocket api (#47096)
This commit is contained in:
@@ -6,6 +6,7 @@ from zwave_js_server.const import LogLevel
|
||||
from zwave_js_server.event import Event
|
||||
from zwave_js_server.exceptions import InvalidNewValue, NotFoundError, SetValueFailed
|
||||
|
||||
from homeassistant.components.websocket_api.const import ERR_NOT_FOUND
|
||||
from homeassistant.components.zwave_js.api import (
|
||||
CONFIG,
|
||||
ENABLED,
|
||||
@@ -76,6 +77,32 @@ async def test_websocket_api(hass, integration, multisensor_6, hass_ws_client):
|
||||
assert result[key]["configuration_value_type"] == "enumerated"
|
||||
assert result[key]["metadata"]["states"]
|
||||
|
||||
# Test getting non-existent node fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 5,
|
||||
TYPE: "zwave_js/node_status",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 99999,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == ERR_NOT_FOUND
|
||||
|
||||
# Test getting non-existent node config params fails
|
||||
await ws_client.send_json(
|
||||
{
|
||||
ID: 6,
|
||||
TYPE: "zwave_js/get_config_parameters",
|
||||
ENTRY_ID: entry.entry_id,
|
||||
NODE_ID: 99999,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
assert not msg["success"]
|
||||
assert msg["error"]["code"] == ERR_NOT_FOUND
|
||||
|
||||
|
||||
async def test_add_node(
|
||||
hass, integration, client, hass_ws_client, nortek_thermostat_added_event
|
||||
|
||||
Reference in New Issue
Block a user