1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Adjust entity registry access in tests (2) (#88960)

This commit is contained in:
epenet
2023-03-01 16:23:36 +01:00
committed by GitHub
parent 09f1c2318d
commit d65dff3f9e
20 changed files with 291 additions and 213 deletions

View File

@@ -3,7 +3,7 @@ from homeassistant.components.climate import PRESET_ECO, PRESET_SLEEP, HVACMode
from homeassistant.components.knx.schema import ClimateSchema
from homeassistant.const import CONF_NAME, STATE_IDLE
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry
from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component
from .conftest import KNXTestKit
@@ -99,7 +99,9 @@ async def test_climate_hvac_mode(hass: HomeAssistant, knx: KNXTestKit) -> None:
await knx.assert_write("1/2/6", (0x01,))
async def test_climate_preset_mode(hass: HomeAssistant, knx: KNXTestKit) -> None:
async def test_climate_preset_mode(
hass: HomeAssistant, knx: KNXTestKit, entity_registry: er.EntityRegistry
) -> None:
"""Test KNX climate preset mode."""
events = async_capture_events(hass, "state_changed")
await knx.setup_integration(
@@ -155,8 +157,7 @@ async def test_climate_preset_mode(hass: HomeAssistant, knx: KNXTestKit) -> None
assert len(knx.xknx.devices[0].device_updated_cbs) == 2
assert len(knx.xknx.devices[1].device_updated_cbs) == 2
# test removing also removes hooks
er = entity_registry.async_get(hass)
er.async_remove("climate.test")
entity_registry.async_remove("climate.test")
await hass.async_block_till_done()
# If we remove the entity the underlying devices should disappear too