Use registry fixtures in tests (v-y) (#118299)

pull/118314/head
epenet 2024-05-28 14:26:14 +02:00 committed by GitHub
parent 8d8696075b
commit f07f183a3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 108 additions and 92 deletions

View File

@ -22,7 +22,9 @@ from tests.common import MockConfigEntry
async def test_init(
hass: HomeAssistant, vera_component_factory: ComponentFactory
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
vera_component_factory: ComponentFactory,
) -> None:
"""Test function."""
vera_device1: pv.VeraBinarySensor = MagicMock(spec=pv.VeraBinarySensor)
@ -42,14 +44,15 @@ async def test_init(
),
)
entity_registry = er.async_get(hass)
entry1 = entity_registry.async_get(entity1_id)
assert entry1
assert entry1.unique_id == "vera_first_serial_1"
async def test_init_from_file(
hass: HomeAssistant, vera_component_factory: ComponentFactory
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
vera_component_factory: ComponentFactory,
) -> None:
"""Test function."""
vera_device1: pv.VeraBinarySensor = MagicMock(spec=pv.VeraBinarySensor)
@ -69,7 +72,6 @@ async def test_init_from_file(
),
)
entity_registry = er.async_get(hass)
entry1 = entity_registry.async_get(entity1_id)
assert entry1
assert entry1.unique_id == "vera_first_serial_1"
@ -77,8 +79,8 @@ async def test_init_from_file(
async def test_multiple_controllers_with_legacy_one(
hass: HomeAssistant,
vera_component_factory: ComponentFactory,
entity_registry: er.EntityRegistry,
vera_component_factory: ComponentFactory,
) -> None:
"""Test multiple controllers with one legacy controller."""
vera_device1: pv.VeraBinarySensor = MagicMock(spec=pv.VeraBinarySensor)
@ -120,8 +122,6 @@ async def test_multiple_controllers_with_legacy_one(
),
)
entity_registry = er.async_get(hass)
entry1 = entity_registry.async_get(entity1_id)
assert entry1
assert entry1.unique_id == "1"

View File

@ -66,6 +66,7 @@ async def test_async_get_config_entry_diagnostics__single_humidifier(
async def test_async_get_device_diagnostics__single_fan(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
hass_client: ClientSessionGenerator,
config_entry: ConfigEntry,
config: ConfigType,
@ -77,7 +78,6 @@ async def test_async_get_device_diagnostics__single_fan(
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()
device_registry = dr.async_get(hass)
device = device_registry.async_get_device(
identifiers={(DOMAIN, "abcdefghabcdefghabcdefghabcdefgh")},
)

View File

@ -20,7 +20,10 @@ from tests.common import MockConfigEntry, load_fixture
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensor(
hass: HomeAssistant, mock_config_entry: MockConfigEntry, snapshot: SnapshotAssertion
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
mock_config_entry: MockConfigEntry,
snapshot: SnapshotAssertion,
) -> None:
"""Test failed update."""
mock_config_entry.add_to_hass(hass)
@ -32,7 +35,6 @@ async def test_sensor(
):
assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()
entity_registry = er.async_get(hass)
for sensor in SENSORS:
entity_id = entity_registry.async_get_entity_id(
SENSOR_DOMAIN, DOMAIN, f"4584_{sensor.key}"

View File

@ -413,7 +413,9 @@ async def test_humidity(
assert float(state.attributes[ATTR_WEATHER_HUMIDITY]) == 80
async def test_custom_units(hass: HomeAssistant, config_flow_fixture: None) -> None:
async def test_custom_units(
hass: HomeAssistant, entity_registry: er.EntityRegistry, config_flow_fixture: None
) -> None:
"""Test custom unit."""
wind_speed_value = 5
wind_speed_unit = UnitOfSpeed.METERS_PER_SECOND
@ -434,8 +436,6 @@ async def test_custom_units(hass: HomeAssistant, config_flow_fixture: None) -> N
"visibility_unit": UnitOfLength.MILES,
}
entity_registry = er.async_get(hass)
entry = entity_registry.async_get_or_create("weather", "test", "very_unique")
entity_registry.async_update_entity_options(entry.entity_id, "weather", set_options)
await hass.async_block_till_done()

View File

@ -42,7 +42,7 @@ async def test_config_no_static(hass: HomeAssistant) -> None:
async def test_static_duplicate_static_entry(
hass: HomeAssistant, pywemo_device
hass: HomeAssistant, entity_registry: er.EntityRegistry, pywemo_device
) -> None:
"""Duplicate static entries are merged into a single entity."""
static_config_entry = f"{MOCK_HOST}:{MOCK_PORT}"
@ -60,12 +60,13 @@ async def test_static_duplicate_static_entry(
},
)
await hass.async_block_till_done()
entity_reg = er.async_get(hass)
entity_entries = list(entity_reg.entities.values())
entity_entries = list(entity_registry.entities.values())
assert len(entity_entries) == 1
async def test_static_config_with_port(hass: HomeAssistant, pywemo_device) -> None:
async def test_static_config_with_port(
hass: HomeAssistant, entity_registry: er.EntityRegistry, pywemo_device
) -> None:
"""Static device with host and port is added and removed."""
assert await async_setup_component(
hass,
@ -78,12 +79,13 @@ async def test_static_config_with_port(hass: HomeAssistant, pywemo_device) -> No
},
)
await hass.async_block_till_done()
entity_reg = er.async_get(hass)
entity_entries = list(entity_reg.entities.values())
entity_entries = list(entity_registry.entities.values())
assert len(entity_entries) == 1
async def test_static_config_without_port(hass: HomeAssistant, pywemo_device) -> None:
async def test_static_config_without_port(
hass: HomeAssistant, entity_registry: er.EntityRegistry, pywemo_device
) -> None:
"""Static device with host and no port is added and removed."""
assert await async_setup_component(
hass,
@ -96,13 +98,13 @@ async def test_static_config_without_port(hass: HomeAssistant, pywemo_device) ->
},
)
await hass.async_block_till_done()
entity_reg = er.async_get(hass)
entity_entries = list(entity_reg.entities.values())
entity_entries = list(entity_registry.entities.values())
assert len(entity_entries) == 1
async def test_reload_config_entry(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
pywemo_device: pywemo.WeMoDevice,
pywemo_registry: pywemo.SubscriptionRegistry,
) -> None:
@ -127,7 +129,6 @@ async def test_reload_config_entry(
pywemo_registry.register.assert_called_once_with(pywemo_device)
pywemo_registry.register.reset_mock()
entity_registry = er.async_get(hass)
entity_entries = list(entity_registry.entities.values())
assert len(entity_entries) == 1
await entity_test_helpers.test_turn_off_state(
@ -165,7 +166,9 @@ async def test_static_config_with_invalid_host(hass: HomeAssistant) -> None:
async def test_static_with_upnp_failure(
hass: HomeAssistant, pywemo_device: pywemo.WeMoDevice
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
pywemo_device: pywemo.WeMoDevice,
) -> None:
"""Device that fails to get state is not added."""
pywemo_device.get_state.side_effect = pywemo.exceptions.ActionException("Failed")
@ -180,13 +183,14 @@ async def test_static_with_upnp_failure(
},
)
await hass.async_block_till_done()
entity_reg = er.async_get(hass)
entity_entries = list(entity_reg.entities.values())
entity_entries = list(entity_registry.entities.values())
assert len(entity_entries) == 0
pywemo_device.get_state.assert_called_once()
async def test_discovery(hass: HomeAssistant, pywemo_registry) -> None:
async def test_discovery(
hass: HomeAssistant, entity_registry: er.EntityRegistry, pywemo_registry
) -> None:
"""Verify that discovery dispatches devices to the platform for setup."""
def create_device(counter):
@ -240,8 +244,7 @@ async def test_discovery(hass: HomeAssistant, pywemo_registry) -> None:
assert mock_discover_statics.call_count == 3
# Verify that the expected number of devices were setup.
entity_reg = er.async_get(hass)
entity_entries = list(entity_reg.entities.values())
entity_entries = list(entity_registry.entities.values())
assert len(entity_entries) == 3
# Verify that hass stops cleanly.

View File

@ -74,6 +74,7 @@ async def test_no_appliances(
async def test_static_attributes(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
mock_aircon1_api: MagicMock,
mock_aircon_api_instances: MagicMock,
) -> None:
@ -81,7 +82,7 @@ async def test_static_attributes(
await init_integration(hass)
for entity_id in ("climate.said1", "climate.said2"):
entry = er.async_get(hass).async_get(entity_id)
entry = entity_registry.async_get(entity_id)
assert entry
assert entry.unique_id == entity_id.split(".")[1]

View File

@ -58,6 +58,7 @@ def mock_dummy_device_from_host_light_fan():
async def test_loading_cover(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
dummy_device_from_host_cover,
) -> None:
"""Test the WiLight configuration entry loading."""
@ -66,8 +67,6 @@ async def test_loading_cover(
assert entry
assert entry.unique_id == WILIGHT_ID
entity_registry = er.async_get(hass)
# First segment of the strip
state = hass.states.get("cover.wl000000000099_1")
assert state

View File

@ -58,6 +58,7 @@ def mock_dummy_device_from_host_light_fan():
async def test_loading_light_fan(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
dummy_device_from_host_light_fan,
) -> None:
"""Test the WiLight configuration entry loading."""
@ -66,8 +67,6 @@ async def test_loading_light_fan(
assert entry
assert entry.unique_id == WILIGHT_ID
entity_registry = er.async_get(hass)
# First segment of the strip
state = hass.states.get("fan.wl000000000099_2")
assert state

View File

@ -131,6 +131,7 @@ def mock_dummy_device_from_host_color():
async def test_loading_light(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
dummy_device_from_host_light_fan,
dummy_get_components_from_model_light,
) -> None:
@ -142,8 +143,6 @@ async def test_loading_light(
assert entry
assert entry.unique_id == WILIGHT_ID
entity_registry = er.async_get(hass)
# First segment of the strip
state = hass.states.get("light.wl000000000099_1")
assert state

View File

@ -64,6 +64,7 @@ def mock_dummy_device_from_host_switch():
async def test_loading_switch(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
dummy_device_from_host_switch,
) -> None:
"""Test the WiLight configuration entry loading."""
@ -72,8 +73,6 @@ async def test_loading_switch(
assert entry
assert entry.unique_id == WILIGHT_ID
entity_registry = er.async_get(hass)
# First segment of the strip
state = hass.states.get("switch.wl000000000099_1_watering")
assert state

View File

@ -21,14 +21,15 @@ from . import (
from tests.common import MockConfigEntry
async def test_binary_sensor_created_from_push_updates(hass: HomeAssistant) -> None:
async def test_binary_sensor_created_from_push_updates(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test a binary sensor created from push updates."""
bulb, _ = await async_setup_integration(hass)
await async_push_update(hass, bulb, {"mac": FAKE_MAC, "src": "pir", "state": True})
entity_id = "binary_sensor.mock_title_occupancy"
entity_registry = er.async_get(hass)
assert entity_registry.async_get(entity_id).unique_id == f"{FAKE_MAC}_occupancy"
state = hass.states.get(entity_id)
assert state.state == STATE_ON
@ -39,7 +40,9 @@ async def test_binary_sensor_created_from_push_updates(hass: HomeAssistant) -> N
assert state.state == STATE_OFF
async def test_binary_sensor_restored_from_registry(hass: HomeAssistant) -> None:
async def test_binary_sensor_restored_from_registry(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test a binary sensor restored from registry with state unknown."""
entry = MockConfigEntry(
domain=wiz.DOMAIN,
@ -49,7 +52,6 @@ async def test_binary_sensor_restored_from_registry(hass: HomeAssistant) -> None
entry.add_to_hass(hass)
bulb = _mocked_wizlight(None, None, None)
entity_registry = er.async_get(hass)
reg_ent = entity_registry.async_get_or_create(
Platform.BINARY_SENSOR, wiz.DOMAIN, OCCUPANCY_UNIQUE_ID.format(bulb.mac)
)

View File

@ -31,21 +31,23 @@ from . import (
)
async def test_light_unique_id(hass: HomeAssistant) -> None:
async def test_light_unique_id(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test a light unique id."""
await async_setup_integration(hass)
entity_id = "light.mock_title"
entity_registry = er.async_get(hass)
assert entity_registry.async_get(entity_id).unique_id == FAKE_MAC
state = hass.states.get(entity_id)
assert state.state == STATE_ON
async def test_light_operation(hass: HomeAssistant) -> None:
async def test_light_operation(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test a light operation."""
bulb, _ = await async_setup_integration(hass)
entity_id = "light.mock_title"
entity_registry = er.async_get(hass)
assert entity_registry.async_get(entity_id).unique_id == FAKE_MAC
state = hass.states.get(entity_id)
assert state.state == STATE_ON

View File

@ -17,12 +17,13 @@ from . import (
)
async def test_speed_operation(hass: HomeAssistant) -> None:
async def test_speed_operation(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test changing a speed."""
bulb, _ = await async_setup_integration(hass, bulb_type=FAKE_DUAL_HEAD_RGBWW_BULB)
await async_push_update(hass, bulb, {"mac": FAKE_MAC})
entity_id = "number.mock_title_effect_speed"
entity_registry = er.async_get(hass)
assert entity_registry.async_get(entity_id).unique_id == f"{FAKE_MAC}_effect_speed"
assert hass.states.get(entity_id).state == STATE_UNAVAILABLE
@ -40,12 +41,13 @@ async def test_speed_operation(hass: HomeAssistant) -> None:
assert hass.states.get(entity_id).state == "30.0"
async def test_ratio_operation(hass: HomeAssistant) -> None:
async def test_ratio_operation(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test changing a dual head ratio."""
bulb, _ = await async_setup_integration(hass, bulb_type=FAKE_DUAL_HEAD_RGBWW_BULB)
await async_push_update(hass, bulb, {"mac": FAKE_MAC})
entity_id = "number.mock_title_dual_head_ratio"
entity_registry = er.async_get(hass)
assert (
entity_registry.async_get(entity_id).unique_id == f"{FAKE_MAC}_dual_head_ratio"
)

View File

@ -17,13 +17,14 @@ from . import (
)
async def test_signal_strength(hass: HomeAssistant) -> None:
async def test_signal_strength(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test signal strength."""
bulb, entry = await async_setup_integration(
hass, bulb_type=FAKE_DUAL_HEAD_RGBWW_BULB
)
entity_id = "sensor.mock_title_signal_strength"
entity_registry = er.async_get(hass)
reg_entry = entity_registry.async_get(entity_id)
assert reg_entry.unique_id == f"{FAKE_MAC}_rssi"
updated_entity = entity_registry.async_update_entity(
@ -41,7 +42,9 @@ async def test_signal_strength(hass: HomeAssistant) -> None:
assert hass.states.get(entity_id).state == "-50"
async def test_power_monitoring(hass: HomeAssistant) -> None:
async def test_power_monitoring(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test power monitoring."""
socket = _mocked_wizlight(None, None, FAKE_SOCKET_WITH_POWER_MONITORING)
socket.power_monitoring = None
@ -50,7 +53,6 @@ async def test_power_monitoring(hass: HomeAssistant) -> None:
hass, wizlight=socket, bulb_type=FAKE_SOCKET_WITH_POWER_MONITORING
)
entity_id = "sensor.mock_title_power"
entity_registry = er.async_get(hass)
reg_entry = entity_registry.async_get(entity_id)
assert reg_entry.unique_id == f"{FAKE_MAC}_power"
updated_entity = entity_registry.async_update_entity(

View File

@ -20,11 +20,12 @@ from . import FAKE_MAC, FAKE_SOCKET, async_push_update, async_setup_integration
from tests.common import async_fire_time_changed
async def test_switch_operation(hass: HomeAssistant) -> None:
async def test_switch_operation(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test switch operation."""
switch, _ = await async_setup_integration(hass, bulb_type=FAKE_SOCKET)
entity_id = "switch.mock_title"
entity_registry = er.async_get(hass)
assert entity_registry.async_get(entity_id).unique_id == FAKE_MAC
assert hass.states.get(entity_id).state == STATE_ON
@ -45,11 +46,12 @@ async def test_switch_operation(hass: HomeAssistant) -> None:
assert hass.states.get(entity_id).state == STATE_ON
async def test_update_fails(hass: HomeAssistant) -> None:
async def test_update_fails(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test switch update fails when push updates are not working."""
switch, _ = await async_setup_integration(hass, bulb_type=FAKE_SOCKET)
entity_id = "switch.mock_title"
entity_registry = er.async_get(hass)
assert entity_registry.async_get(entity_id).unique_id == FAKE_MAC
assert hass.states.get(entity_id).state == STATE_ON

View File

@ -457,59 +457,59 @@ async def test_volume_while_mute(hass: HomeAssistant) -> None:
assert not ws66i.zones[11].mute
async def test_first_run_with_available_zones(hass: HomeAssistant) -> None:
async def test_first_run_with_available_zones(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test first run with all zones available."""
ws66i = MockWs66i()
await _setup_ws66i(hass, ws66i)
registry = er.async_get(hass)
entry = registry.async_get(ZONE_7_ID)
entry = entity_registry.async_get(ZONE_7_ID)
assert not entry.disabled
async def test_first_run_with_failing_zones(hass: HomeAssistant) -> None:
async def test_first_run_with_failing_zones(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test first run with failed zones."""
ws66i = MockWs66i()
with patch.object(MockWs66i, "zone_status", return_value=None):
await _setup_ws66i(hass, ws66i)
registry = er.async_get(hass)
entry = registry.async_get(ZONE_1_ID)
entry = entity_registry.async_get(ZONE_1_ID)
assert entry is None
entry = registry.async_get(ZONE_7_ID)
entry = entity_registry.async_get(ZONE_7_ID)
assert entry is None
async def test_register_all_entities(hass: HomeAssistant) -> None:
async def test_register_all_entities(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test run with all entities registered."""
ws66i = MockWs66i()
await _setup_ws66i(hass, ws66i)
registry = er.async_get(hass)
entry = registry.async_get(ZONE_1_ID)
entry = entity_registry.async_get(ZONE_1_ID)
assert not entry.disabled
entry = registry.async_get(ZONE_7_ID)
entry = entity_registry.async_get(ZONE_7_ID)
assert not entry.disabled
async def test_register_entities_in_1_amp_only(hass: HomeAssistant) -> None:
async def test_register_entities_in_1_amp_only(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test run with only zones 11-16 registered."""
ws66i = MockWs66i(fail_zone_check=[21])
await _setup_ws66i(hass, ws66i)
registry = er.async_get(hass)
entry = registry.async_get(ZONE_1_ID)
entry = entity_registry.async_get(ZONE_1_ID)
assert not entry.disabled
entry = registry.async_get(ZONE_2_ID)
entry = entity_registry.async_get(ZONE_2_ID)
assert not entry.disabled
entry = registry.async_get(ZONE_7_ID)
entry = entity_registry.async_get(ZONE_7_ID)
assert entry is None

View File

@ -51,7 +51,9 @@ from . import (
from tests.common import MockConfigEntry, async_fire_time_changed
async def test_ip_changes_fallback_discovery(hass: HomeAssistant) -> None:
async def test_ip_changes_fallback_discovery(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test Yeelight ip changes and we fallback to discovery."""
config_entry = MockConfigEntry(
domain=DOMAIN, data={CONF_ID: ID, CONF_HOST: "5.5.5.5"}, unique_id=ID
@ -84,7 +86,6 @@ async def test_ip_changes_fallback_discovery(hass: HomeAssistant) -> None:
binary_sensor_entity_id = ENTITY_BINARY_SENSOR_TEMPLATE.format(
f"yeelight_color_{SHORT_ID}"
)
entity_registry = er.async_get(hass)
assert entity_registry.async_get(binary_sensor_entity_id) is not None
# Make sure we can still reload with the new ip right after we change it
@ -93,7 +94,6 @@ async def test_ip_changes_fallback_discovery(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
assert config_entry.state is ConfigEntryState.LOADED
entity_registry = er.async_get(hass)
assert entity_registry.async_get(binary_sensor_entity_id) is not None
@ -278,7 +278,9 @@ async def test_setup_import(hass: HomeAssistant) -> None:
assert entry.data[CONF_ID] == "0x000000000015243f"
async def test_unique_ids_device(hass: HomeAssistant) -> None:
async def test_unique_ids_device(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test Yeelight unique IDs from yeelight device IDs."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@ -293,7 +295,6 @@ async def test_unique_ids_device(hass: HomeAssistant) -> None:
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
entity_registry = er.async_get(hass)
assert (
entity_registry.async_get(ENTITY_BINARY_SENSOR).unique_id
== f"{ID}-nightlight_sensor"
@ -303,7 +304,9 @@ async def test_unique_ids_device(hass: HomeAssistant) -> None:
assert entity_registry.async_get(ENTITY_AMBILIGHT).unique_id == f"{ID}-ambilight"
async def test_unique_ids_entry(hass: HomeAssistant) -> None:
async def test_unique_ids_entry(
hass: HomeAssistant, entity_registry: er.EntityRegistry
) -> None:
"""Test Yeelight unique IDs from entry IDs."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@ -318,7 +321,6 @@ async def test_unique_ids_entry(hass: HomeAssistant) -> None:
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
entity_registry = er.async_get(hass)
assert (
entity_registry.async_get(ENTITY_BINARY_SENSOR).unique_id
== f"{config_entry.entry_id}-nightlight_sensor"

View File

@ -776,7 +776,9 @@ async def test_state_already_set_avoid_ratelimit(hass: HomeAssistant) -> None:
async def test_device_types(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test different device types."""
mocked_bulb = _mocked_bulb()
@ -825,8 +827,7 @@ async def test_device_types(
assert dict(state.attributes) == target_properties
await hass.config_entries.async_unload(config_entry.entry_id)
await hass.config_entries.async_remove(config_entry.entry_id)
registry = er.async_get(hass)
registry.async_clear_config_entry(config_entry.entry_id)
entity_registry.async_clear_config_entry(config_entry.entry_id)
mocked_bulb.last_properties["nl_br"] = original_nightlight_brightness
# nightlight as a setting of the main entity
@ -847,7 +848,7 @@ async def test_device_types(
await hass.config_entries.async_unload(config_entry.entry_id)
await hass.config_entries.async_remove(config_entry.entry_id)
registry.async_clear_config_entry(config_entry.entry_id)
entity_registry.async_clear_config_entry(config_entry.entry_id)
await hass.async_block_till_done()
mocked_bulb.last_properties.pop("active_mode")
@ -870,7 +871,7 @@ async def test_device_types(
await hass.config_entries.async_unload(config_entry.entry_id)
await hass.config_entries.async_remove(config_entry.entry_id)
registry.async_clear_config_entry(config_entry.entry_id)
entity_registry.async_clear_config_entry(config_entry.entry_id)
await hass.async_block_till_done()
bright = round(255 * int(PROPERTIES["bright"]) / 100)

View File

@ -118,11 +118,12 @@ async def test_expired_token_refresh_client_error(
async def test_device_info(
hass: HomeAssistant, setup_integration: ComponentSetup
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
setup_integration: ComponentSetup,
) -> None:
"""Test device info."""
await setup_integration()
device_registry = dr.async_get(hass)
entry = hass.config_entries.async_entries(DOMAIN)[0]
channel_id = entry.options[CONF_CHANNELS][0]