From 78b21b1ad1835d26bac8cb0955c5e41031e013fb Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 9 Mar 2021 14:24:34 +0100 Subject: [PATCH] Update tests a-b to use async_get() instead of async_get_registry() (#47651) --- .../components/abode/test_alarm_control_panel.py | 3 ++- tests/components/abode/test_binary_sensor.py | 3 ++- tests/components/abode/test_camera.py | 3 ++- tests/components/abode/test_cover.py | 3 ++- tests/components/abode/test_light.py | 3 ++- tests/components/abode/test_lock.py | 3 ++- tests/components/abode/test_sensor.py | 3 ++- tests/components/abode/test_switch.py | 3 ++- tests/components/accuweather/test_sensor.py | 9 +++++---- tests/components/accuweather/test_weather.py | 5 +++-- .../advantage_air/test_binary_sensor.py | 3 ++- tests/components/advantage_air/test_climate.py | 3 ++- tests/components/advantage_air/test_cover.py | 3 ++- tests/components/advantage_air/test_sensor.py | 3 ++- tests/components/advantage_air/test_switch.py | 4 ++-- tests/components/airly/test_air_quality.py | 3 ++- tests/components/airly/test_sensor.py | 3 ++- tests/components/asuswrt/test_sensor.py | 3 ++- tests/components/atag/test_climate.py | 4 ++-- tests/components/atag/test_sensors.py | 4 ++-- tests/components/atag/test_water_heater.py | 4 ++-- tests/components/august/test_binary_sensor.py | 4 ++-- tests/components/august/test_lock.py | 6 +++--- tests/components/august/test_sensor.py | 16 ++++++++-------- tests/components/awair/test_sensor.py | 14 +++++++------- tests/components/axis/test_init.py | 4 ++-- tests/components/blebox/conftest.py | 3 ++- tests/components/blebox/test_air_quality.py | 4 ++-- tests/components/blebox/test_climate.py | 4 ++-- tests/components/blebox/test_cover.py | 8 ++++---- tests/components/blebox/test_light.py | 8 ++++---- tests/components/blebox/test_sensor.py | 4 ++-- tests/components/blebox/test_switch.py | 8 ++++---- tests/components/bond/test_cover.py | 3 ++- tests/components/bond/test_fan.py | 3 ++- tests/components/bond/test_init.py | 8 ++++---- tests/components/bond/test_light.py | 13 +++++++------ tests/components/bond/test_switch.py | 3 ++- tests/components/brother/test_sensor.py | 5 +++-- tests/test_config_entries.py | 3 ++- 40 files changed, 110 insertions(+), 86 deletions(-) diff --git a/tests/components/abode/test_alarm_control_panel.py b/tests/components/abode/test_alarm_control_panel.py index 63ae20441f5..55ff22b9ee3 100644 --- a/tests/components/abode/test_alarm_control_panel.py +++ b/tests/components/abode/test_alarm_control_panel.py @@ -16,6 +16,7 @@ from homeassistant.const import ( STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, ) +from homeassistant.helpers import entity_registry as er from .common import setup_platform @@ -25,7 +26,7 @@ DEVICE_ID = "alarm_control_panel.abode_alarm" async def test_entity_registry(hass): """Tests that the devices are registered in the entity registry.""" await setup_platform(hass, ALARM_DOMAIN) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) entry = entity_registry.async_get(DEVICE_ID) # Abode alarm device unique_id is the MAC address diff --git a/tests/components/abode/test_binary_sensor.py b/tests/components/abode/test_binary_sensor.py index a826191ccf3..e4aa08c7f5f 100644 --- a/tests/components/abode/test_binary_sensor.py +++ b/tests/components/abode/test_binary_sensor.py @@ -11,6 +11,7 @@ from homeassistant.const import ( ATTR_FRIENDLY_NAME, STATE_OFF, ) +from homeassistant.helpers import entity_registry as er from .common import setup_platform @@ -18,7 +19,7 @@ from .common import setup_platform async def test_entity_registry(hass): """Tests that the devices are registered in the entity registry.""" await setup_platform(hass, BINARY_SENSOR_DOMAIN) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) entry = entity_registry.async_get("binary_sensor.front_door") assert entry.unique_id == "2834013428b6035fba7d4054aa7b25a3" diff --git a/tests/components/abode/test_camera.py b/tests/components/abode/test_camera.py index 06540955464..7dc943a0a74 100644 --- a/tests/components/abode/test_camera.py +++ b/tests/components/abode/test_camera.py @@ -4,6 +4,7 @@ from unittest.mock import patch from homeassistant.components.abode.const import DOMAIN as ABODE_DOMAIN from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN from homeassistant.const import ATTR_ENTITY_ID, STATE_IDLE +from homeassistant.helpers import entity_registry as er from .common import setup_platform @@ -11,7 +12,7 @@ from .common import setup_platform async def test_entity_registry(hass): """Tests that the devices are registered in the entity registry.""" await setup_platform(hass, CAMERA_DOMAIN) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) entry = entity_registry.async_get("camera.test_cam") assert entry.unique_id == "d0a3a1c316891ceb00c20118aae2a133" diff --git a/tests/components/abode/test_cover.py b/tests/components/abode/test_cover.py index bb1b8fceffb..edd40a86707 100644 --- a/tests/components/abode/test_cover.py +++ b/tests/components/abode/test_cover.py @@ -10,6 +10,7 @@ from homeassistant.const import ( SERVICE_OPEN_COVER, STATE_CLOSED, ) +from homeassistant.helpers import entity_registry as er from .common import setup_platform @@ -19,7 +20,7 @@ DEVICE_ID = "cover.garage_door" async def test_entity_registry(hass): """Tests that the devices are registered in the entity registry.""" await setup_platform(hass, COVER_DOMAIN) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) entry = entity_registry.async_get(DEVICE_ID) assert entry.unique_id == "61cbz3b542d2o33ed2fz02721bda3324" diff --git a/tests/components/abode/test_light.py b/tests/components/abode/test_light.py index f0eee4b209b..b5160aece2a 100644 --- a/tests/components/abode/test_light.py +++ b/tests/components/abode/test_light.py @@ -16,6 +16,7 @@ from homeassistant.const import ( SERVICE_TURN_ON, STATE_ON, ) +from homeassistant.helpers import entity_registry as er from .common import setup_platform @@ -25,7 +26,7 @@ DEVICE_ID = "light.living_room_lamp" async def test_entity_registry(hass): """Tests that the devices are registered in the entity registry.""" await setup_platform(hass, LIGHT_DOMAIN) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) entry = entity_registry.async_get(DEVICE_ID) assert entry.unique_id == "741385f4388b2637df4c6b398fe50581" diff --git a/tests/components/abode/test_lock.py b/tests/components/abode/test_lock.py index 45e17861d33..c688b6f02bc 100644 --- a/tests/components/abode/test_lock.py +++ b/tests/components/abode/test_lock.py @@ -10,6 +10,7 @@ from homeassistant.const import ( SERVICE_UNLOCK, STATE_LOCKED, ) +from homeassistant.helpers import entity_registry as er from .common import setup_platform @@ -19,7 +20,7 @@ DEVICE_ID = "lock.test_lock" async def test_entity_registry(hass): """Tests that the devices are registered in the entity registry.""" await setup_platform(hass, LOCK_DOMAIN) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) entry = entity_registry.async_get(DEVICE_ID) assert entry.unique_id == "51cab3b545d2o34ed7fz02731bda5324" diff --git a/tests/components/abode/test_sensor.py b/tests/components/abode/test_sensor.py index d99fac50dde..5e3195430ab 100644 --- a/tests/components/abode/test_sensor.py +++ b/tests/components/abode/test_sensor.py @@ -9,6 +9,7 @@ from homeassistant.const import ( PERCENTAGE, TEMP_CELSIUS, ) +from homeassistant.helpers import entity_registry as er from .common import setup_platform @@ -16,7 +17,7 @@ from .common import setup_platform async def test_entity_registry(hass): """Tests that the devices are registered in the entity registry.""" await setup_platform(hass, SENSOR_DOMAIN) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) entry = entity_registry.async_get("sensor.environment_sensor_humidity") assert entry.unique_id == "13545b21f4bdcd33d9abd461f8443e65-humidity" diff --git a/tests/components/abode/test_switch.py b/tests/components/abode/test_switch.py index 3ec9648d87d..829c5e8ae37 100644 --- a/tests/components/abode/test_switch.py +++ b/tests/components/abode/test_switch.py @@ -13,6 +13,7 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, ) +from homeassistant.helpers import entity_registry as er from .common import setup_platform @@ -25,7 +26,7 @@ DEVICE_UID = "0012a4d3614cb7e2b8c9abea31d2fb2a" async def test_entity_registry(hass): """Tests that the devices are registered in the entity registry.""" await setup_platform(hass, SWITCH_DOMAIN) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) entry = entity_registry.async_get(AUTOMATION_ID) assert entry.unique_id == AUTOMATION_UID diff --git a/tests/components/accuweather/test_sensor.py b/tests/components/accuweather/test_sensor.py index 361422883d4..bafad72ec0b 100644 --- a/tests/components/accuweather/test_sensor.py +++ b/tests/components/accuweather/test_sensor.py @@ -22,6 +22,7 @@ from homeassistant.const import ( TIME_HOURS, UV_INDEX, ) +from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component from homeassistant.util.dt import utcnow @@ -32,7 +33,7 @@ from tests.components.accuweather import init_integration async def test_sensor_without_forecast(hass): """Test states of the sensor without forecast.""" await init_integration(hass) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) state = hass.states.get("sensor.home_cloud_ceiling") assert state @@ -94,7 +95,7 @@ async def test_sensor_without_forecast(hass): async def test_sensor_with_forecast(hass): """Test states of the sensor with forecast.""" await init_integration(hass, forecast=True) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) state = hass.states.get("sensor.home_hours_of_sun_0d") assert state @@ -166,7 +167,7 @@ async def test_sensor_with_forecast(hass): async def test_sensor_disabled(hass): """Test sensor disabled by default.""" await init_integration(hass) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) entry = registry.async_get("sensor.home_apparent_temperature") assert entry @@ -185,7 +186,7 @@ async def test_sensor_disabled(hass): async def test_sensor_enabled_without_forecast(hass): """Test enabling an advanced sensor.""" - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) registry.async_get_or_create( SENSOR_DOMAIN, diff --git a/tests/components/accuweather/test_weather.py b/tests/components/accuweather/test_weather.py index 0c1559ef0d6..8190d96e634 100644 --- a/tests/components/accuweather/test_weather.py +++ b/tests/components/accuweather/test_weather.py @@ -23,6 +23,7 @@ from homeassistant.components.weather import ( ATTR_WEATHER_WIND_SPEED, ) from homeassistant.const import ATTR_ATTRIBUTION, ATTR_ENTITY_ID, STATE_UNAVAILABLE +from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component from homeassistant.util.dt import utcnow @@ -33,7 +34,7 @@ from tests.components.accuweather import init_integration async def test_weather_without_forecast(hass): """Test states of the weather without forecast.""" await init_integration(hass) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) state = hass.states.get("weather.home") assert state @@ -56,7 +57,7 @@ async def test_weather_without_forecast(hass): async def test_weather_with_forecast(hass): """Test states of the weather with forecast.""" await init_integration(hass, forecast=True) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) state = hass.states.get("weather.home") assert state diff --git a/tests/components/advantage_air/test_binary_sensor.py b/tests/components/advantage_air/test_binary_sensor.py index d0b1a90aaad..dee4b9fd99a 100644 --- a/tests/components/advantage_air/test_binary_sensor.py +++ b/tests/components/advantage_air/test_binary_sensor.py @@ -1,6 +1,7 @@ """Test the Advantage Air Binary Sensor Platform.""" from homeassistant.const import STATE_OFF, STATE_ON +from homeassistant.helpers import entity_registry as er from tests.components.advantage_air import ( TEST_SET_RESPONSE, @@ -24,7 +25,7 @@ async def test_binary_sensor_async_setup_entry(hass, aioclient_mock): ) await add_mock_config(hass) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert len(aioclient_mock.mock_calls) == 1 diff --git a/tests/components/advantage_air/test_climate.py b/tests/components/advantage_air/test_climate.py index 7eb1729a5db..ea0cf025462 100644 --- a/tests/components/advantage_air/test_climate.py +++ b/tests/components/advantage_air/test_climate.py @@ -22,6 +22,7 @@ from homeassistant.components.climate.const import ( SERVICE_SET_TEMPERATURE, ) from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE +from homeassistant.helpers import entity_registry as er from tests.components.advantage_air import ( TEST_SET_RESPONSE, @@ -45,7 +46,7 @@ async def test_climate_async_setup_entry(hass, aioclient_mock): ) await add_mock_config(hass) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert len(aioclient_mock.mock_calls) == 1 diff --git a/tests/components/advantage_air/test_cover.py b/tests/components/advantage_air/test_cover.py index 18fd4f05b5a..29f0d288fdb 100644 --- a/tests/components/advantage_air/test_cover.py +++ b/tests/components/advantage_air/test_cover.py @@ -15,6 +15,7 @@ from homeassistant.components.cover import ( SERVICE_SET_COVER_POSITION, ) from homeassistant.const import ATTR_ENTITY_ID, STATE_OPEN +from homeassistant.helpers import entity_registry as er from tests.components.advantage_air import ( TEST_SET_RESPONSE, @@ -39,7 +40,7 @@ async def test_cover_async_setup_entry(hass, aioclient_mock): await add_mock_config(hass) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert len(aioclient_mock.mock_calls) == 1 diff --git a/tests/components/advantage_air/test_sensor.py b/tests/components/advantage_air/test_sensor.py index e420ab978fd..684b965d94f 100644 --- a/tests/components/advantage_air/test_sensor.py +++ b/tests/components/advantage_air/test_sensor.py @@ -8,6 +8,7 @@ from homeassistant.components.advantage_air.sensor import ( ADVANTAGE_AIR_SET_COUNTDOWN_VALUE, ) from homeassistant.const import ATTR_ENTITY_ID +from homeassistant.helpers import entity_registry as er from tests.components.advantage_air import ( TEST_SET_RESPONSE, @@ -31,7 +32,7 @@ async def test_sensor_platform(hass, aioclient_mock): ) await add_mock_config(hass) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert len(aioclient_mock.mock_calls) == 1 diff --git a/tests/components/advantage_air/test_switch.py b/tests/components/advantage_air/test_switch.py index f45477adc70..1a78025df70 100644 --- a/tests/components/advantage_air/test_switch.py +++ b/tests/components/advantage_air/test_switch.py @@ -1,5 +1,4 @@ """Test the Advantage Air Switch Platform.""" - from json import loads from homeassistant.components.advantage_air.const import ( @@ -12,6 +11,7 @@ from homeassistant.components.switch import ( SERVICE_TURN_ON, ) from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF +from homeassistant.helpers import entity_registry as er from tests.components.advantage_air import ( TEST_SET_RESPONSE, @@ -36,7 +36,7 @@ async def test_cover_async_setup_entry(hass, aioclient_mock): await add_mock_config(hass) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert len(aioclient_mock.mock_calls) == 1 diff --git a/tests/components/airly/test_air_quality.py b/tests/components/airly/test_air_quality.py index 24a98cbf155..de059e84aa4 100644 --- a/tests/components/airly/test_air_quality.py +++ b/tests/components/airly/test_air_quality.py @@ -23,6 +23,7 @@ from homeassistant.const import ( HTTP_INTERNAL_SERVER_ERROR, STATE_UNAVAILABLE, ) +from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component from homeassistant.util.dt import utcnow @@ -35,7 +36,7 @@ from tests.components.airly import init_integration async def test_air_quality(hass, aioclient_mock): """Test states of the air_quality.""" await init_integration(hass, aioclient_mock) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) state = hass.states.get("air_quality.home") assert state diff --git a/tests/components/airly/test_sensor.py b/tests/components/airly/test_sensor.py index abc53294bbc..925f3acb6d2 100644 --- a/tests/components/airly/test_sensor.py +++ b/tests/components/airly/test_sensor.py @@ -17,6 +17,7 @@ from homeassistant.const import ( STATE_UNAVAILABLE, TEMP_CELSIUS, ) +from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component from homeassistant.util.dt import utcnow @@ -29,7 +30,7 @@ from tests.components.airly import init_integration async def test_sensor(hass, aioclient_mock): """Test states of the sensor.""" await init_integration(hass, aioclient_mock) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) state = hass.states.get("sensor.home_humidity") assert state diff --git a/tests/components/asuswrt/test_sensor.py b/tests/components/asuswrt/test_sensor.py index 4a8a1f27653..e69af0cd322 100644 --- a/tests/components/asuswrt/test_sensor.py +++ b/tests/components/asuswrt/test_sensor.py @@ -19,6 +19,7 @@ from homeassistant.const import ( STATE_HOME, STATE_NOT_HOME, ) +from homeassistant.helpers import entity_registry as er from homeassistant.util.dt import utcnow from tests.common import MockConfigEntry, async_fire_time_changed @@ -64,7 +65,7 @@ def mock_controller_connect(): async def test_sensors(hass, connect): """Test creating an AsusWRT sensor.""" - entity_reg = await hass.helpers.entity_registry.async_get_registry() + entity_reg = er.async_get(hass) # init config entry config_entry = MockConfigEntry( diff --git a/tests/components/atag/test_climate.py b/tests/components/atag/test_climate.py index 3d511821baf..e263ade7c75 100644 --- a/tests/components/atag/test_climate.py +++ b/tests/components/atag/test_climate.py @@ -1,5 +1,4 @@ """Tests for the Atag climate platform.""" - from unittest.mock import PropertyMock, patch from homeassistant.components.atag import CLIMATE, DOMAIN @@ -19,6 +18,7 @@ from homeassistant.components.homeassistant import ( ) from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_UNKNOWN from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component from tests.components.atag import UID, init_integration @@ -33,7 +33,7 @@ async def test_climate( """Test the creation and values of Atag climate device.""" with patch("pyatag.entities.Climate.status"): entry = await init_integration(hass, aioclient_mock) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert registry.async_is_registered(CLIMATE_ID) entry = registry.async_get(CLIMATE_ID) diff --git a/tests/components/atag/test_sensors.py b/tests/components/atag/test_sensors.py index e7bf4df44e9..aeefcb2789b 100644 --- a/tests/components/atag/test_sensors.py +++ b/tests/components/atag/test_sensors.py @@ -1,7 +1,7 @@ """Tests for the Atag sensor platform.""" - from homeassistant.components.atag.sensor import SENSORS from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er from tests.components.atag import UID, init_integration from tests.test_util.aiohttp import AiohttpClientMocker @@ -12,7 +12,7 @@ async def test_sensors( ) -> None: """Test the creation of ATAG sensors.""" entry = await init_integration(hass, aioclient_mock) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) for item in SENSORS: sensor_id = "_".join(f"sensor.{item}".lower().split()) diff --git a/tests/components/atag/test_water_heater.py b/tests/components/atag/test_water_heater.py index 5eb219fa3bc..4c78302224d 100644 --- a/tests/components/atag/test_water_heater.py +++ b/tests/components/atag/test_water_heater.py @@ -1,11 +1,11 @@ """Tests for the Atag water heater platform.""" - from unittest.mock import patch from homeassistant.components.atag import DOMAIN, WATER_HEATER from homeassistant.components.water_heater import SERVICE_SET_TEMPERATURE from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er from tests.components.atag import UID, init_integration from tests.test_util.aiohttp import AiohttpClientMocker @@ -19,7 +19,7 @@ async def test_water_heater( """Test the creation of Atag water heater.""" with patch("pyatag.entities.DHW.status"): entry = await init_integration(hass, aioclient_mock) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert registry.async_is_registered(WATER_HEATER_ID) entry = registry.async_get(WATER_HEATER_ID) diff --git a/tests/components/august/test_binary_sensor.py b/tests/components/august/test_binary_sensor.py index 763f9f9528f..0e337813f52 100644 --- a/tests/components/august/test_binary_sensor.py +++ b/tests/components/august/test_binary_sensor.py @@ -1,5 +1,4 @@ """The binary_sensor tests for the august platform.""" - from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN from homeassistant.const import ( ATTR_ENTITY_ID, @@ -9,6 +8,7 @@ from homeassistant.const import ( STATE_ON, STATE_UNAVAILABLE, ) +from homeassistant.helpers import device_registry as dr from tests.components.august.mocks import ( _create_august_with_devices, @@ -119,7 +119,7 @@ async def test_doorbell_device_registry(hass): doorbell_one = await _mock_doorbell_from_fixture(hass, "get_doorbell.offline.json") await _create_august_with_devices(hass, [doorbell_one]) - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) reg_device = device_registry.async_get_device(identifiers={("august", "tmt100")}) assert reg_device.model == "hydra1" diff --git a/tests/components/august/test_lock.py b/tests/components/august/test_lock.py index d013da30ff6..dadd6de2d4f 100644 --- a/tests/components/august/test_lock.py +++ b/tests/components/august/test_lock.py @@ -1,5 +1,4 @@ """The lock tests for the august platform.""" - from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN from homeassistant.const import ( ATTR_ENTITY_ID, @@ -9,6 +8,7 @@ from homeassistant.const import ( STATE_UNKNOWN, STATE_UNLOCKED, ) +from homeassistant.helpers import device_registry as dr, entity_registry as er from tests.components.august.mocks import ( _create_august_with_devices, @@ -23,7 +23,7 @@ async def test_lock_device_registry(hass): lock_one = await _mock_doorsense_enabled_august_lock_detail(hass) await _create_august_with_devices(hass, [lock_one]) - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) reg_device = device_registry.async_get_device( identifiers={("august", "online_with_doorsense")} @@ -90,7 +90,7 @@ async def test_one_lock_operation(hass): assert lock_online_with_doorsense_name.state == STATE_LOCKED # No activity means it will be unavailable until the activity feed has data - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) lock_operator_sensor = entity_registry.async_get( "sensor.online_with_doorsense_name_operator" ) diff --git a/tests/components/august/test_sensor.py b/tests/components/august/test_sensor.py index fb7ddfde979..254f88ef4e9 100644 --- a/tests/components/august/test_sensor.py +++ b/tests/components/august/test_sensor.py @@ -1,6 +1,6 @@ """The sensor tests for the august platform.""" - from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, PERCENTAGE, STATE_UNKNOWN +from homeassistant.helpers import entity_registry as er from tests.components.august.mocks import ( _create_august_with_devices, @@ -29,7 +29,7 @@ async def test_create_doorbell_offline(hass): """Test creation of a doorbell that is offline.""" doorbell_one = await _mock_doorbell_from_fixture(hass, "get_doorbell.offline.json") await _create_august_with_devices(hass, [doorbell_one]) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) sensor_tmt100_name_battery = hass.states.get("sensor.tmt100_name_battery") assert sensor_tmt100_name_battery.state == "81" @@ -55,7 +55,7 @@ async def test_create_lock_with_linked_keypad(hass): """Test creation of a lock with a linked keypad that both have a battery.""" lock_one = await _mock_lock_from_fixture(hass, "get_lock.doorsense_init.json") await _create_august_with_devices(hass, [lock_one]) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) sensor_a6697750d607098bae8d6baa11ef8063_name_battery = hass.states.get( "sensor.a6697750d607098bae8d6baa11ef8063_name_battery" @@ -85,7 +85,7 @@ async def test_create_lock_with_low_battery_linked_keypad(hass): """Test creation of a lock with a linked keypad that both have a battery.""" lock_one = await _mock_lock_from_fixture(hass, "get_lock.low_keypad_battery.json") await _create_august_with_devices(hass, [lock_one]) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) sensor_a6697750d607098bae8d6baa11ef8063_name_battery = hass.states.get( "sensor.a6697750d607098bae8d6baa11ef8063_name_battery" @@ -133,7 +133,7 @@ async def test_lock_operator_bluetooth(hass): ) await _create_august_with_devices(hass, [lock_one], activities=activities) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) lock_operator_sensor = entity_registry.async_get( "sensor.online_with_doorsense_name_operator" ) @@ -177,7 +177,7 @@ async def test_lock_operator_keypad(hass): ) await _create_august_with_devices(hass, [lock_one], activities=activities) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) lock_operator_sensor = entity_registry.async_get( "sensor.online_with_doorsense_name_operator" ) @@ -219,7 +219,7 @@ async def test_lock_operator_remote(hass): activities = await _mock_activities_from_fixture(hass, "get_activity.lock.json") await _create_august_with_devices(hass, [lock_one], activities=activities) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) lock_operator_sensor = entity_registry.async_get( "sensor.online_with_doorsense_name_operator" ) @@ -263,7 +263,7 @@ async def test_lock_operator_autorelock(hass): ) await _create_august_with_devices(hass, [lock_one], activities=activities) - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) lock_operator_sensor = entity_registry.async_get( "sensor.online_with_doorsense_name_operator" ) diff --git a/tests/components/awair/test_sensor.py b/tests/components/awair/test_sensor.py index 0fcbab99a3a..b37e8dbf5d2 100644 --- a/tests/components/awair/test_sensor.py +++ b/tests/components/awair/test_sensor.py @@ -1,5 +1,4 @@ """Tests for the Awair sensor platform.""" - from unittest.mock import patch from homeassistant.components.awair.const import ( @@ -27,6 +26,7 @@ from homeassistant.const import ( STATE_UNAVAILABLE, TEMP_CELSIUS, ) +from homeassistant.helpers import entity_registry as er from .const import ( AWAIR_UUID, @@ -74,7 +74,7 @@ async def test_awair_gen1_sensors(hass): fixtures = [USER_FIXTURE, DEVICES_FIXTURE, GEN1_DATA_FIXTURE] await setup_awair(hass, fixtures) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert_expected_properties( hass, @@ -170,7 +170,7 @@ async def test_awair_gen2_sensors(hass): fixtures = [USER_FIXTURE, DEVICES_FIXTURE, GEN2_DATA_FIXTURE] await setup_awair(hass, fixtures) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert_expected_properties( hass, @@ -204,7 +204,7 @@ async def test_awair_mint_sensors(hass): fixtures = [USER_FIXTURE, DEVICES_FIXTURE, MINT_DATA_FIXTURE] await setup_awair(hass, fixtures) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert_expected_properties( hass, @@ -246,7 +246,7 @@ async def test_awair_glow_sensors(hass): fixtures = [USER_FIXTURE, DEVICES_FIXTURE, GLOW_DATA_FIXTURE] await setup_awair(hass, fixtures) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert_expected_properties( hass, @@ -266,7 +266,7 @@ async def test_awair_omni_sensors(hass): fixtures = [USER_FIXTURE, DEVICES_FIXTURE, OMNI_DATA_FIXTURE] await setup_awair(hass, fixtures) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert_expected_properties( hass, @@ -319,7 +319,7 @@ async def test_awair_unavailable(hass): fixtures = [USER_FIXTURE, DEVICES_FIXTURE, GEN1_DATA_FIXTURE] await setup_awair(hass, fixtures) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) assert_expected_properties( hass, diff --git a/tests/components/axis/test_init.py b/tests/components/axis/test_init.py index 36a603ea7b3..5ca9fb1eb8d 100644 --- a/tests/components/axis/test_init.py +++ b/tests/components/axis/test_init.py @@ -13,7 +13,7 @@ from homeassistant.const import ( CONF_PORT, CONF_USERNAME, ) -from homeassistant.helpers import entity_registry +from homeassistant.helpers import entity_registry as er from homeassistant.helpers.device_registry import format_mac from homeassistant.setup import async_setup_component @@ -83,7 +83,7 @@ async def test_migrate_entry(hass): assert not entry.unique_id # Create entity entry to migrate to new unique ID - registry = await entity_registry.async_get_registry(hass) + registry = er.async_get(hass) registry.async_get_or_create( BINARY_SENSOR_DOMAIN, AXIS_DOMAIN, diff --git a/tests/components/blebox/conftest.py b/tests/components/blebox/conftest.py index c603c15c32b..a63a0090c3a 100644 --- a/tests/components/blebox/conftest.py +++ b/tests/components/blebox/conftest.py @@ -7,6 +7,7 @@ import pytest from homeassistant.components.blebox.const import DOMAIN from homeassistant.const import CONF_HOST, CONF_PORT +from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry @@ -84,7 +85,7 @@ async def async_setup_entities(hass, config, entity_ids): assert await async_setup_component(hass, DOMAIN, config) await hass.async_block_till_done() - entity_registry = await hass.helpers.entity_registry.async_get_registry() + entity_registry = er.async_get(hass) return [entity_registry.async_get(entity_id) for entity_id in entity_ids] diff --git a/tests/components/blebox/test_air_quality.py b/tests/components/blebox/test_air_quality.py index 4f1f6dff671..8b5bc67d4bc 100644 --- a/tests/components/blebox/test_air_quality.py +++ b/tests/components/blebox/test_air_quality.py @@ -1,5 +1,4 @@ """Blebox air_quality tests.""" - import logging from unittest.mock import AsyncMock, PropertyMock @@ -8,6 +7,7 @@ import pytest from homeassistant.components.air_quality import ATTR_PM_0_1, ATTR_PM_2_5, ATTR_PM_10 from homeassistant.const import ATTR_ICON, STATE_UNKNOWN +from homeassistant.helpers import device_registry as dr from .conftest import async_setup_entity, mock_feature @@ -49,7 +49,7 @@ async def test_init(airsensor, hass, config): assert state.state == STATE_UNKNOWN - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My air sensor" diff --git a/tests/components/blebox/test_climate.py b/tests/components/blebox/test_climate.py index baaa5a5009e..0b27846e654 100644 --- a/tests/components/blebox/test_climate.py +++ b/tests/components/blebox/test_climate.py @@ -1,5 +1,4 @@ """BleBox climate entities tests.""" - import logging from unittest.mock import AsyncMock, PropertyMock @@ -28,6 +27,7 @@ from homeassistant.const import ( ATTR_TEMPERATURE, STATE_UNKNOWN, ) +from homeassistant.helpers import device_registry as dr from .conftest import async_setup_entity, mock_feature @@ -79,7 +79,7 @@ async def test_init(saunabox, hass, config): assert state.state == STATE_UNKNOWN - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My sauna" diff --git a/tests/components/blebox/test_cover.py b/tests/components/blebox/test_cover.py index a5d3a8f705b..8355411a0bb 100644 --- a/tests/components/blebox/test_cover.py +++ b/tests/components/blebox/test_cover.py @@ -1,5 +1,4 @@ """BleBox cover entities tests.""" - import logging from unittest.mock import AsyncMock, PropertyMock @@ -30,6 +29,7 @@ from homeassistant.const import ( SERVICE_STOP_COVER, STATE_UNKNOWN, ) +from homeassistant.helpers import device_registry as dr from .conftest import async_setup_entity, mock_feature @@ -117,7 +117,7 @@ async def test_init_gatecontroller(gatecontroller, hass, config): assert ATTR_CURRENT_POSITION not in state.attributes assert state.state == STATE_UNKNOWN - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My gate controller" @@ -147,7 +147,7 @@ async def test_init_shutterbox(shutterbox, hass, config): assert ATTR_CURRENT_POSITION not in state.attributes assert state.state == STATE_UNKNOWN - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My shutter" @@ -179,7 +179,7 @@ async def test_init_gatebox(gatebox, hass, config): assert ATTR_CURRENT_POSITION not in state.attributes assert state.state == STATE_UNKNOWN - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My gatebox" diff --git a/tests/components/blebox/test_light.py b/tests/components/blebox/test_light.py index 5d9e5709e4d..6c8c26fe938 100644 --- a/tests/components/blebox/test_light.py +++ b/tests/components/blebox/test_light.py @@ -1,5 +1,4 @@ """BleBox light entities tests.""" - import logging from unittest.mock import AsyncMock, PropertyMock @@ -21,6 +20,7 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, ) +from homeassistant.helpers import device_registry as dr from homeassistant.util import color from .conftest import async_setup_entity, mock_feature @@ -65,7 +65,7 @@ async def test_dimmer_init(dimmer, hass, config): assert state.attributes[ATTR_BRIGHTNESS] == 65 assert state.state == STATE_ON - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My dimmer" @@ -236,7 +236,7 @@ async def test_wlightbox_s_init(wlightbox_s, hass, config): assert ATTR_BRIGHTNESS not in state.attributes assert state.state == STATE_OFF - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My wLightBoxS" @@ -339,7 +339,7 @@ async def test_wlightbox_init(wlightbox, hass, config): assert ATTR_BRIGHTNESS not in state.attributes assert state.state == STATE_OFF - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My wLightBox" diff --git a/tests/components/blebox/test_sensor.py b/tests/components/blebox/test_sensor.py index aeb726cc726..2281c4ea68c 100644 --- a/tests/components/blebox/test_sensor.py +++ b/tests/components/blebox/test_sensor.py @@ -1,5 +1,4 @@ """Blebox sensors tests.""" - import logging from unittest.mock import AsyncMock, PropertyMock @@ -13,6 +12,7 @@ from homeassistant.const import ( STATE_UNKNOWN, TEMP_CELSIUS, ) +from homeassistant.helpers import device_registry as dr from .conftest import async_setup_entity, mock_feature @@ -49,7 +49,7 @@ async def test_init(tempsensor, hass, config): assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS assert state.state == STATE_UNKNOWN - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My temperature sensor" diff --git a/tests/components/blebox/test_switch.py b/tests/components/blebox/test_switch.py index e2bc1240510..e67c0479cb3 100644 --- a/tests/components/blebox/test_switch.py +++ b/tests/components/blebox/test_switch.py @@ -1,5 +1,4 @@ """Blebox switch tests.""" - import logging from unittest.mock import AsyncMock, PropertyMock @@ -14,6 +13,7 @@ from homeassistant.const import ( STATE_OFF, STATE_ON, ) +from homeassistant.helpers import device_registry as dr from .conftest import ( async_setup_entities, @@ -58,7 +58,7 @@ async def test_switchbox_init(switchbox, hass, config): assert state.state == STATE_OFF - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My switch box" @@ -204,7 +204,7 @@ async def test_switchbox_d_init(switchbox_d, hass, config): assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_SWITCH assert state.state == STATE_OFF # NOTE: should instead be STATE_UNKNOWN? - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My relays" @@ -221,7 +221,7 @@ async def test_switchbox_d_init(switchbox_d, hass, config): assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_SWITCH assert state.state == STATE_OFF # NOTE: should instead be STATE_UNKNOWN? - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get(entry.device_id) assert device.name == "My relays" diff --git a/tests/components/bond/test_cover.py b/tests/components/bond/test_cover.py index dbb8ee0f3b7..f516d84d50a 100644 --- a/tests/components/bond/test_cover.py +++ b/tests/components/bond/test_cover.py @@ -11,6 +11,7 @@ from homeassistant.const import ( SERVICE_OPEN_COVER, SERVICE_STOP_COVER, ) +from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_registry import EntityRegistry from homeassistant.util import utcnow @@ -39,7 +40,7 @@ async def test_entity_registry(hass: core.HomeAssistant): bond_device_id="test-device-id", ) - registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + registry: EntityRegistry = er.async_get(hass) entity = registry.entities["cover.name_1"] assert entity.unique_id == "test-hub-id_test-device-id" diff --git a/tests/components/bond/test_fan.py b/tests/components/bond/test_fan.py index 49a6e4a5b68..ca3bc9ac7e7 100644 --- a/tests/components/bond/test_fan.py +++ b/tests/components/bond/test_fan.py @@ -18,6 +18,7 @@ from homeassistant.components.fan import ( SPEED_OFF, ) from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON +from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_registry import EntityRegistry from homeassistant.util import utcnow @@ -71,7 +72,7 @@ async def test_entity_registry(hass: core.HomeAssistant): bond_device_id="test-device-id", ) - registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + registry: EntityRegistry = er.async_get(hass) entity = registry.entities["fan.name_1"] assert entity.unique_id == "test-hub-id_test-device-id" diff --git a/tests/components/bond/test_init.py b/tests/components/bond/test_init.py index 7346acc5276..0bba04b4d97 100644 --- a/tests/components/bond/test_init.py +++ b/tests/components/bond/test_init.py @@ -79,7 +79,7 @@ async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAss assert config_entry.unique_id == "test-bond-id" # verify hub device is registered correctly - device_registry = await dr.async_get_registry(hass) + device_registry = dr.async_get(hass) hub = device_registry.async_get_device(identifiers={(DOMAIN, "test-bond-id")}) assert hub.name == "bond-name" assert hub.manufacturer == "Olibra" @@ -127,7 +127,7 @@ async def test_old_identifiers_are_removed(hass: HomeAssistant): old_identifers = (DOMAIN, "device_id") new_identifiers = (DOMAIN, "test-bond-id", "device_id") - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device_registry.async_get_or_create( config_entry_id=config_entry.entry_id, identifiers={old_identifers}, @@ -204,7 +204,7 @@ async def test_smart_by_bond_device_suggested_area(hass: HomeAssistant): assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.unique_id == "test-bond-id" - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get_device(identifiers={(DOMAIN, "test-bond-id")}) assert device is not None assert device.suggested_area == "Den" @@ -250,7 +250,7 @@ async def test_bridge_device_suggested_area(hass: HomeAssistant): assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.unique_id == "test-bond-id" - device_registry = await hass.helpers.device_registry.async_get_registry() + device_registry = dr.async_get(hass) device = device_registry.async_get_device(identifiers={(DOMAIN, "test-bond-id")}) assert device is not None assert device.suggested_area == "Office" diff --git a/tests/components/bond/test_light.py b/tests/components/bond/test_light.py index 59d051fbe86..e59efcd7bcf 100644 --- a/tests/components/bond/test_light.py +++ b/tests/components/bond/test_light.py @@ -16,6 +16,7 @@ from homeassistant.const import ( SERVICE_TURN_OFF, SERVICE_TURN_ON, ) +from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_registry import EntityRegistry from homeassistant.util import utcnow @@ -107,7 +108,7 @@ async def test_fan_entity_registry(hass: core.HomeAssistant): bond_device_id="test-device-id", ) - registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + registry: EntityRegistry = er.async_get(hass) entity = registry.entities["light.fan_name"] assert entity.unique_id == "test-hub-id_test-device-id" @@ -122,7 +123,7 @@ async def test_fan_up_light_entity_registry(hass: core.HomeAssistant): bond_device_id="test-device-id", ) - registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + registry: EntityRegistry = er.async_get(hass) entity = registry.entities["light.fan_name_up_light"] assert entity.unique_id == "test-hub-id_test-device-id_up_light" @@ -137,7 +138,7 @@ async def test_fan_down_light_entity_registry(hass: core.HomeAssistant): bond_device_id="test-device-id", ) - registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + registry: EntityRegistry = er.async_get(hass) entity = registry.entities["light.fan_name_down_light"] assert entity.unique_id == "test-hub-id_test-device-id_down_light" @@ -152,7 +153,7 @@ async def test_fireplace_entity_registry(hass: core.HomeAssistant): bond_device_id="test-device-id", ) - registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + registry: EntityRegistry = er.async_get(hass) entity = registry.entities["light.fireplace_name"] assert entity.unique_id == "test-hub-id_test-device-id" @@ -167,7 +168,7 @@ async def test_fireplace_with_light_entity_registry(hass: core.HomeAssistant): bond_device_id="test-device-id", ) - registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + registry: EntityRegistry = er.async_get(hass) entity_flame = registry.entities["light.fireplace_name"] assert entity_flame.unique_id == "test-hub-id_test-device-id" entity_light = registry.entities["light.fireplace_name_light"] @@ -184,7 +185,7 @@ async def test_light_entity_registry(hass: core.HomeAssistant): bond_device_id="test-device-id", ) - registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + registry: EntityRegistry = er.async_get(hass) entity = registry.entities["light.light_name"] assert entity.unique_id == "test-hub-id_test-device-id" diff --git a/tests/components/bond/test_switch.py b/tests/components/bond/test_switch.py index f2568f5fb99..94a9179d3a7 100644 --- a/tests/components/bond/test_switch.py +++ b/tests/components/bond/test_switch.py @@ -6,6 +6,7 @@ from bond_api import Action, DeviceType from homeassistant import core from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_ON +from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_registry import EntityRegistry from homeassistant.util import utcnow @@ -34,7 +35,7 @@ async def test_entity_registry(hass: core.HomeAssistant): bond_device_id="test-device-id", ) - registry: EntityRegistry = await hass.helpers.entity_registry.async_get_registry() + registry: EntityRegistry = er.async_get(hass) entity = registry.entities["switch.name_1"] assert entity.unique_id == "test-hub-id_test-device-id" diff --git a/tests/components/brother/test_sensor.py b/tests/components/brother/test_sensor.py index b386b0753b7..ab48721dec5 100644 --- a/tests/components/brother/test_sensor.py +++ b/tests/components/brother/test_sensor.py @@ -14,6 +14,7 @@ from homeassistant.const import ( PERCENTAGE, STATE_UNAVAILABLE, ) +from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component from homeassistant.util.dt import UTC, utcnow @@ -28,7 +29,7 @@ async def test_sensors(hass): """Test states of the sensors.""" entry = await init_integration(hass, skip_setup=True) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) # Pre-create registry entries for disabled by default sensors registry.async_get_or_create( @@ -241,7 +242,7 @@ async def test_disabled_by_default_sensors(hass): """Test the disabled by default Brother sensors.""" await init_integration(hass) - registry = await hass.helpers.entity_registry.async_get_registry() + registry = er.async_get(hass) state = hass.states.get("sensor.hl_l2340dw_uptime") assert state is None diff --git a/tests/test_config_entries.py b/tests/test_config_entries.py index 8a479a802e4..9abb68e97c9 100644 --- a/tests/test_config_entries.py +++ b/tests/test_config_entries.py @@ -8,6 +8,7 @@ import pytest from homeassistant import config_entries, data_entry_flow, loader from homeassistant.core import callback from homeassistant.exceptions import ConfigEntryNotReady +from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component from homeassistant.util import dt @@ -299,7 +300,7 @@ async def test_remove_entry(hass, manager): assert len(hass.states.async_all()) == 1 # Check entity got added to entity registry - ent_reg = await hass.helpers.entity_registry.async_get_registry() + ent_reg = er.async_get(hass) assert len(ent_reg.entities) == 1 entity_entry = list(ent_reg.entities.values())[0] assert entity_entry.config_entry_id == entry.entry_id