Update h* tests to use entity & device registry fixtures (#103866)
* Update h* tests to use entity & device registry fixtures * Add missed lines
This commit is contained in:
parent
3a531f5698
commit
eda475fe25
48 changed files with 330 additions and 240 deletions
|
@ -29,7 +29,10 @@ async def test_hmip_load_all_supported_devices(
|
|||
|
||||
|
||||
async def test_hmip_remove_device(
|
||||
hass: HomeAssistant, default_mock_hap_factory
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
default_mock_hap_factory,
|
||||
) -> None:
|
||||
"""Test Remove of hmip device."""
|
||||
entity_id = "light.treppe_ch"
|
||||
|
@ -46,9 +49,6 @@ async def test_hmip_remove_device(
|
|||
assert ha_state.state == STATE_ON
|
||||
assert hmip_device
|
||||
|
||||
device_registry = dr.async_get(hass)
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
pre_device_count = len(device_registry.devices)
|
||||
pre_entity_count = len(entity_registry.entities)
|
||||
pre_mapping_count = len(mock_hap.hmip_device_by_entity_id)
|
||||
|
@ -63,7 +63,11 @@ async def test_hmip_remove_device(
|
|||
|
||||
|
||||
async def test_hmip_add_device(
|
||||
hass: HomeAssistant, default_mock_hap_factory, hmip_config_entry
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
default_mock_hap_factory,
|
||||
hmip_config_entry,
|
||||
) -> None:
|
||||
"""Test Remove of hmip device."""
|
||||
entity_id = "light.treppe_ch"
|
||||
|
@ -80,9 +84,6 @@ async def test_hmip_add_device(
|
|||
assert ha_state.state == STATE_ON
|
||||
assert hmip_device
|
||||
|
||||
device_registry = dr.async_get(hass)
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
pre_device_count = len(device_registry.devices)
|
||||
pre_entity_count = len(entity_registry.entities)
|
||||
pre_mapping_count = len(mock_hap.hmip_device_by_entity_id)
|
||||
|
@ -112,7 +113,12 @@ async def test_hmip_add_device(
|
|||
assert len(new_hap.hmip_device_by_entity_id) == pre_mapping_count
|
||||
|
||||
|
||||
async def test_hmip_remove_group(hass: HomeAssistant, default_mock_hap_factory) -> None:
|
||||
async def test_hmip_remove_group(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
default_mock_hap_factory,
|
||||
) -> None:
|
||||
"""Test Remove of hmip group."""
|
||||
entity_id = "switch.strom_group"
|
||||
entity_name = "Strom Group"
|
||||
|
@ -126,9 +132,6 @@ async def test_hmip_remove_group(hass: HomeAssistant, default_mock_hap_factory)
|
|||
assert ha_state.state == STATE_ON
|
||||
assert hmip_device
|
||||
|
||||
device_registry = dr.async_get(hass)
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
pre_device_count = len(device_registry.devices)
|
||||
pre_entity_count = len(entity_registry.entities)
|
||||
pre_mapping_count = len(mock_hap.hmip_device_by_entity_id)
|
||||
|
@ -254,7 +257,10 @@ async def test_hmip_reset_energy_counter_services(
|
|||
|
||||
|
||||
async def test_hmip_multi_area_device(
|
||||
hass: HomeAssistant, default_mock_hap_factory
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
default_mock_hap_factory,
|
||||
) -> None:
|
||||
"""Test multi area device. Check if devices are created and referenced."""
|
||||
entity_id = "binary_sensor.wired_eingangsmodul_32_fach_channel5"
|
||||
|
@ -270,12 +276,10 @@ async def test_hmip_multi_area_device(
|
|||
assert ha_state
|
||||
|
||||
# get the entity
|
||||
entity_registry = er.async_get(hass)
|
||||
entity = entity_registry.async_get(ha_state.entity_id)
|
||||
assert entity
|
||||
|
||||
# get the device
|
||||
device_registry = dr.async_get(hass)
|
||||
device = device_registry.async_get(entity.device_id)
|
||||
assert device.name == "Wired Eingangsmodul – 32-fach"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue