Use registry fixtures in tests (m-n) (#118291)
This commit is contained in:
parent
8837c50da7
commit
ead0e797c1
22 changed files with 185 additions and 166 deletions
|
@ -6,7 +6,6 @@ from homeassistant.components.nexia.const import DOMAIN
|
|||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .util import async_init_integration
|
||||
|
@ -21,23 +20,24 @@ async def test_setup_retry_client_os_error(hass: HomeAssistant) -> None:
|
|||
|
||||
|
||||
async def test_device_remove_devices(
|
||||
hass: HomeAssistant, hass_ws_client: WebSocketGenerator
|
||||
hass: HomeAssistant,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test we can only remove a device that no longer exists."""
|
||||
await async_setup_component(hass, "config", {})
|
||||
config_entry = await async_init_integration(hass)
|
||||
entry_id = config_entry.entry_id
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
registry: EntityRegistry = er.async_get(hass)
|
||||
entity = registry.entities["sensor.nick_office_temperature"]
|
||||
entity = entity_registry.entities["sensor.nick_office_temperature"]
|
||||
|
||||
live_zone_device_entry = device_registry.async_get(entity.device_id)
|
||||
client = await hass_ws_client(hass)
|
||||
response = await client.remove_device(live_zone_device_entry.id, entry_id)
|
||||
assert not response["success"]
|
||||
|
||||
entity = registry.entities["sensor.master_suite_humidity"]
|
||||
entity = entity_registry.entities["sensor.master_suite_humidity"]
|
||||
live_thermostat_device_entry = device_registry.async_get(entity.device_id)
|
||||
response = await client.remove_device(live_thermostat_device_entry.id, entry_id)
|
||||
assert not response["success"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue