mirror of https://github.com/home-assistant/core
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
"""Test the Z-Wave JS helpers module."""
|
|
|
|
import voluptuous as vol
|
|
|
|
from homeassistant.components.zwave_js.helpers import (
|
|
async_get_node_status_sensor_entity_id,
|
|
async_get_nodes_from_area_id,
|
|
get_value_state_schema,
|
|
)
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import area_registry as ar, device_registry as dr
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
async def test_async_get_node_status_sensor_entity_id(
|
|
hass: HomeAssistant, device_registry: dr.DeviceRegistry
|
|
) -> None:
|
|
"""Test async_get_node_status_sensor_entity_id for non zwave_js device."""
|
|
config_entry = MockConfigEntry()
|
|
config_entry.add_to_hass(hass)
|
|
device = device_registry.async_get_or_create(
|
|
config_entry_id=config_entry.entry_id,
|
|
identifiers={("test", "test")},
|
|
)
|
|
assert async_get_node_status_sensor_entity_id(hass, device.id) is None
|
|
|
|
|
|
async def test_async_get_nodes_from_area_id(
|
|
hass: HomeAssistant, area_registry: ar.AreaRegistry
|
|
) -> None:
|
|
"""Test async_get_nodes_from_area_id."""
|
|
area = area_registry.async_create("test")
|
|
assert not async_get_nodes_from_area_id(hass, area.id)
|
|
|
|
|
|
async def test_get_value_state_schema_boolean_config_value(
|
|
hass: HomeAssistant, client, aeon_smart_switch_6
|
|
) -> None:
|
|
"""Test get_value_state_schema for boolean config value."""
|
|
schema_validator = get_value_state_schema(
|
|
aeon_smart_switch_6.values["102-112-0-255"]
|
|
)
|
|
assert isinstance(schema_validator, vol.Coerce)
|
|
assert schema_validator.type is bool
|