Use registry fixtures in tests (z) (#118300)
This commit is contained in:
parent
106cb4cfb7
commit
0b2aac8f4c
26 changed files with 526 additions and 372 deletions
|
@ -126,6 +126,7 @@ async def test_no_driver(
|
|||
|
||||
async def test_network_status(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
multisensor_6,
|
||||
controller_state,
|
||||
client,
|
||||
|
@ -158,8 +159,7 @@ async def test_network_status(
|
|||
assert result["controller"]["inclusion_state"] == InclusionState.IDLE
|
||||
|
||||
# Try API call with device ID
|
||||
dev_reg = dr.async_get(hass)
|
||||
device = dev_reg.async_get_device(
|
||||
device = device_registry.async_get_device(
|
||||
identifiers={(DOMAIN, "3245146787-52")},
|
||||
)
|
||||
assert device
|
||||
|
@ -251,6 +251,7 @@ async def test_network_status(
|
|||
|
||||
async def test_subscribe_node_status(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
multisensor_6_state,
|
||||
client,
|
||||
integration,
|
||||
|
@ -265,8 +266,7 @@ async def test_subscribe_node_status(
|
|||
driver = client.driver
|
||||
driver.controller.nodes[node.node_id] = node
|
||||
|
||||
dev_reg = dr.async_get(hass)
|
||||
device = dev_reg.async_get_or_create(
|
||||
device = device_registry.async_get_or_create(
|
||||
config_entry_id=entry.entry_id, identifiers={get_device_id(driver, node)}
|
||||
)
|
||||
|
||||
|
@ -461,6 +461,7 @@ async def test_node_metadata(
|
|||
|
||||
async def test_node_alerts(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
wallmote_central_scene,
|
||||
integration,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
|
@ -468,8 +469,7 @@ async def test_node_alerts(
|
|||
"""Test the node comments websocket command."""
|
||||
ws_client = await hass_ws_client(hass)
|
||||
|
||||
dev_reg = dr.async_get(hass)
|
||||
device = dev_reg.async_get_device(identifiers={(DOMAIN, "3245146787-35")})
|
||||
device = device_registry.async_get_device(identifiers={(DOMAIN, "3245146787-35")})
|
||||
assert device
|
||||
|
||||
await ws_client.send_json(
|
||||
|
@ -1650,6 +1650,7 @@ async def test_cancel_inclusion_exclusion(
|
|||
|
||||
async def test_remove_node(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
integration,
|
||||
client,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
|
@ -1686,10 +1687,8 @@ async def test_remove_node(
|
|||
msg = await ws_client.receive_json()
|
||||
assert msg["event"]["event"] == "exclusion started"
|
||||
|
||||
dev_reg = dr.async_get(hass)
|
||||
|
||||
# Create device registry entry for mock node
|
||||
device = dev_reg.async_get_or_create(
|
||||
device = device_registry.async_get_or_create(
|
||||
config_entry_id=entry.entry_id,
|
||||
identifiers={(DOMAIN, "3245146787-67")},
|
||||
name="Node 67",
|
||||
|
@ -1701,7 +1700,7 @@ async def test_remove_node(
|
|||
assert msg["event"]["event"] == "node removed"
|
||||
|
||||
# Verify device was removed from device registry
|
||||
device = dev_reg.async_get_device(
|
||||
device = device_registry.async_get_device(
|
||||
identifiers={(DOMAIN, "3245146787-67")},
|
||||
)
|
||||
assert device is None
|
||||
|
@ -1761,6 +1760,7 @@ async def test_remove_node(
|
|||
|
||||
async def test_replace_failed_node(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
nortek_thermostat,
|
||||
integration,
|
||||
client,
|
||||
|
@ -1772,10 +1772,8 @@ async def test_replace_failed_node(
|
|||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
|
||||
dev_reg = dr.async_get(hass)
|
||||
|
||||
# Create device registry entry for mock node
|
||||
device = dev_reg.async_get_or_create(
|
||||
device = device_registry.async_get_or_create(
|
||||
config_entry_id=entry.entry_id,
|
||||
identifiers={(DOMAIN, "3245146787-67")},
|
||||
name="Node 67",
|
||||
|
@ -1871,7 +1869,7 @@ async def test_replace_failed_node(
|
|||
|
||||
# Verify device was removed from device registry
|
||||
assert (
|
||||
dev_reg.async_get_device(
|
||||
device_registry.async_get_device(
|
||||
identifiers={(DOMAIN, "3245146787-67")},
|
||||
)
|
||||
is None
|
||||
|
@ -2110,6 +2108,7 @@ async def test_replace_failed_node(
|
|||
|
||||
async def test_remove_failed_node(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
nortek_thermostat,
|
||||
integration,
|
||||
client,
|
||||
|
@ -2153,10 +2152,8 @@ async def test_remove_failed_node(
|
|||
msg = await ws_client.receive_json()
|
||||
assert msg["success"]
|
||||
|
||||
dev_reg = dr.async_get(hass)
|
||||
|
||||
# Create device registry entry for mock node
|
||||
device = dev_reg.async_get_or_create(
|
||||
device = device_registry.async_get_or_create(
|
||||
config_entry_id=entry.entry_id,
|
||||
identifiers={(DOMAIN, "3245146787-67")},
|
||||
name="Node 67",
|
||||
|
@ -2169,7 +2166,7 @@ async def test_remove_failed_node(
|
|||
|
||||
# Verify device was removed from device registry
|
||||
assert (
|
||||
dev_reg.async_get_device(
|
||||
device_registry.async_get_device(
|
||||
identifiers={(DOMAIN, "3245146787-67")},
|
||||
)
|
||||
is None
|
||||
|
@ -4674,6 +4671,7 @@ async def test_subscribe_node_statistics(
|
|||
|
||||
async def test_hard_reset_controller(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
client,
|
||||
integration,
|
||||
listen_block,
|
||||
|
@ -4683,8 +4681,7 @@ async def test_hard_reset_controller(
|
|||
entry = integration
|
||||
ws_client = await hass_ws_client(hass)
|
||||
|
||||
dev_reg = dr.async_get(hass)
|
||||
device = dev_reg.async_get_device(
|
||||
device = device_registry.async_get_device(
|
||||
identifiers={get_device_id(client.driver, client.driver.controller.nodes[1])}
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue