Update i-j* tests to use entity & device registry fixtures (#103900)

This commit is contained in:
Jan-Philipp Benecke 2023-11-13 11:51:55 +01:00 committed by GitHub
parent be2cee228c
commit 92b3c0c96b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 199 additions and 151 deletions

View file

@ -57,18 +57,20 @@ async def mock_connection(*args, **kwargs):
return True
async def test_lock_lock(hass: HomeAssistant) -> None:
async def test_lock_lock(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
) -> None:
"""Test locking an Insteon lock device."""
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_INPUT_PLM)
config_entry.add_to_hass(hass)
registry_entity = er.async_get(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
try:
lock = registry_entity.async_get("lock.device_55_55_55_55_55_55")
lock = entity_registry.async_get("lock.device_55_55_55_55_55_55")
state = hass.states.get(lock.entity_id)
assert state.state is STATE_UNLOCKED
@ -82,19 +84,21 @@ async def test_lock_lock(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
async def test_lock_unlock(hass: HomeAssistant) -> None:
async def test_lock_unlock(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
) -> None:
"""Test locking an Insteon lock device."""
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_INPUT_PLM)
config_entry.add_to_hass(hass)
registry_entity = er.async_get(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
devices["55.55.55"].groups[1].set_value(255)
try:
lock = registry_entity.async_get("lock.device_55_55_55_55_55_55")
lock = entity_registry.async_get("lock.device_55_55_55_55_55_55")
state = hass.states.get(lock.entity_id)
assert state.state is STATE_LOCKED