Update tests c-h to use registry async_get (#47652)
This commit is contained in:
parent
ba2978c693
commit
87e7cebd36
49 changed files with 165 additions and 138 deletions
|
@ -1,4 +1,5 @@
|
|||
"""Test against characteristics captured from a eufycam."""
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
|
@ -12,7 +13,7 @@ async def test_eufycam_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "anker_eufycam.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Check that the camera is correctly found and set up
|
||||
camera_id = "camera.eufycam2_0000"
|
||||
|
@ -32,7 +33,7 @@ async def test_eufycam_setup(hass):
|
|||
assert camera_state.state == "idle"
|
||||
assert camera_state.attributes["supported_features"] == 0
|
||||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
device = device_registry.async_get(camera.device_id)
|
||||
assert device.manufacturer == "Anker"
|
||||
|
|
|
@ -5,6 +5,7 @@ https://github.com/home-assistant/core/issues/20957
|
|||
"""
|
||||
|
||||
from homeassistant.components.light import SUPPORT_BRIGHTNESS, SUPPORT_COLOR
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
|
@ -18,7 +19,7 @@ async def test_aqara_gateway_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "aqara_gateway.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Check that the light is correctly found and set up
|
||||
alarm_id = "alarm_control_panel.aqara_hub_1563"
|
||||
|
@ -48,7 +49,7 @@ async def test_aqara_gateway_setup(hass):
|
|||
SUPPORT_BRIGHTNESS | SUPPORT_COLOR
|
||||
)
|
||||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
# All the entities are services of the same accessory
|
||||
# So it looks at the protocol like a single physical device
|
||||
|
|
|
@ -7,6 +7,8 @@ service-label-index despite not being linked to a service-label.
|
|||
https://github.com/home-assistant/core/pull/39090
|
||||
"""
|
||||
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from tests.common import assert_lists_same, async_get_device_automations
|
||||
from tests.components.homekit_controller.common import (
|
||||
setup_accessories_from_file,
|
||||
|
@ -19,7 +21,7 @@ async def test_aqara_switch_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "aqara_switch.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
battery_id = "sensor.programmable_switch_battery"
|
||||
battery = entity_registry.async_get(battery_id)
|
||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.components.climate.const import (
|
|||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
|
@ -30,7 +31,7 @@ async def test_ecobee3_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "ecobee3.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
climate = entity_registry.async_get("climate.homew")
|
||||
assert climate.unique_id == "homekit-123456789012-16"
|
||||
|
@ -73,7 +74,7 @@ async def test_ecobee3_setup(hass):
|
|||
occ3 = entity_registry.async_get("binary_sensor.basement")
|
||||
assert occ3.unique_id == "homekit-AB3C-56"
|
||||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
climate_device = device_registry.async_get(climate.device_id)
|
||||
assert climate_device.manufacturer == "ecobee Inc."
|
||||
|
@ -112,7 +113,7 @@ async def test_ecobee3_setup_from_cache(hass, hass_storage):
|
|||
|
||||
await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
climate = entity_registry.async_get("climate.homew")
|
||||
assert climate.unique_id == "homekit-123456789012-16"
|
||||
|
@ -131,7 +132,7 @@ async def test_ecobee3_setup_connection_failure(hass):
|
|||
"""Test that Ecbobee can be correctly setup from its cached entity map."""
|
||||
accessories = await setup_accessories_from_file(hass, "ecobee3.json")
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Test that the connection fails during initial setup.
|
||||
# No entities should be created.
|
||||
|
@ -170,7 +171,7 @@ async def test_ecobee3_setup_connection_failure(hass):
|
|||
|
||||
async def test_ecobee3_add_sensors_at_runtime(hass):
|
||||
"""Test that new sensors are automatically added."""
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Set up a base Ecobee 3 with no additional sensors.
|
||||
# There shouldn't be any entities but climate visible.
|
||||
|
|
|
@ -4,6 +4,8 @@ Regression tests for Ecobee occupancy.
|
|||
https://github.com/home-assistant/core/issues/31827
|
||||
"""
|
||||
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
setup_accessories_from_file,
|
||||
|
@ -16,7 +18,7 @@ async def test_ecobee_occupancy_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "ecobee_occupancy.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
sensor = entity_registry.async_get("binary_sensor.master_fan")
|
||||
assert sensor.unique_id == "homekit-111111111111-56"
|
||||
|
@ -27,7 +29,7 @@ async def test_ecobee_occupancy_setup(hass):
|
|||
sensor_state = await sensor_helper.poll_and_get_state()
|
||||
assert sensor_state.attributes["friendly_name"] == "Master Fan"
|
||||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
device = device_registry.async_get(sensor.device_id)
|
||||
assert device.manufacturer == "ecobee Inc."
|
||||
|
|
|
@ -5,6 +5,7 @@ from homeassistant.components.fan import (
|
|||
SUPPORT_OSCILLATE,
|
||||
SUPPORT_SET_SPEED,
|
||||
)
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
|
@ -20,7 +21,7 @@ async def test_homeassistant_bridge_fan_setup(hass):
|
|||
)
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Check that the fan is correctly found and set up
|
||||
fan_id = "fan.living_room_fan"
|
||||
|
@ -42,7 +43,7 @@ async def test_homeassistant_bridge_fan_setup(hass):
|
|||
SUPPORT_DIRECTION | SUPPORT_SET_SPEED | SUPPORT_OSCILLATE
|
||||
)
|
||||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
device = device_registry.async_get(fan.device_id)
|
||||
assert device.manufacturer == "Home Assistant"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Tests for handling accessories on a Hue bridge via HomeKit."""
|
||||
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.common import assert_lists_same, async_get_device_automations
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
|
@ -13,7 +15,7 @@ async def test_hue_bridge_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "hue_bridge.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Check that the battery is correctly found and set up
|
||||
battery_id = "sensor.hue_dimmer_switch_battery"
|
||||
|
@ -28,7 +30,7 @@ async def test_hue_bridge_setup(hass):
|
|||
assert battery_state.attributes["icon"] == "mdi:battery"
|
||||
assert battery_state.state == "100"
|
||||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
device = device_registry.async_get(battery.device_id)
|
||||
assert device.manufacturer == "Philips"
|
||||
|
|
|
@ -8,6 +8,7 @@ from aiohomekit.testing import FakePairing
|
|||
import pytest
|
||||
|
||||
from homeassistant.components.light import SUPPORT_BRIGHTNESS, SUPPORT_COLOR
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
@ -25,7 +26,7 @@ async def test_koogeek_ls1_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "koogeek_ls1.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Assert that the entity is correctly added to the entity registry
|
||||
entry = entity_registry.async_get("light.koogeek_ls1_20833f")
|
||||
|
@ -44,7 +45,7 @@ async def test_koogeek_ls1_setup(hass):
|
|||
SUPPORT_BRIGHTNESS | SUPPORT_COLOR
|
||||
)
|
||||
|
||||
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.manufacturer == "Koogeek"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Make sure that existing Koogeek P1EU support isn't broken."""
|
||||
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
setup_accessories_from_file,
|
||||
|
@ -12,8 +14,8 @@ async def test_koogeek_p1eu_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "koogeek_p1eu.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
# Check that the switch entity is handled correctly
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ from homeassistant.components.climate.const import (
|
|||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
|
@ -21,7 +22,7 @@ async def test_lennox_e30_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "lennox_e30.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
climate = entity_registry.async_get("climate.lennox")
|
||||
assert climate.unique_id == "homekit-XXXXXXXX-100"
|
||||
|
@ -35,7 +36,7 @@ async def test_lennox_e30_setup(hass):
|
|||
SUPPORT_TARGET_TEMPERATURE | SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
)
|
||||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
device = device_registry.async_get(climate.device_id)
|
||||
assert device.manufacturer == "Lennox"
|
||||
|
|
|
@ -5,6 +5,7 @@ from homeassistant.components.media_player.const import (
|
|||
SUPPORT_PLAY,
|
||||
SUPPORT_SELECT_SOURCE,
|
||||
)
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.common import async_get_device_automations
|
||||
from tests.components.homekit_controller.common import (
|
||||
|
@ -19,7 +20,7 @@ async def test_lg_tv(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "lg_tv.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Assert that the entity is correctly added to the entity registry
|
||||
entry = entity_registry.async_get("media_player.lg_webos_tv_af80")
|
||||
|
@ -54,7 +55,7 @@ async def test_lg_tv(hass):
|
|||
# CURRENT_MEDIA_STATE. Therefore "ok" is the best we can say.
|
||||
assert state.state == "ok"
|
||||
|
||||
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.manufacturer == "LG Electronics"
|
||||
|
|
|
@ -4,6 +4,8 @@ Make sure that existing RainMachine support isn't broken.
|
|||
https://github.com/home-assistant/core/issues/31745
|
||||
"""
|
||||
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
setup_accessories_from_file,
|
||||
|
@ -16,7 +18,7 @@ async def test_rainmachine_pro_8_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "rainmachine-pro-8.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Assert that the entity is correctly added to the entity registry
|
||||
entry = entity_registry.async_get("switch.rainmachine_00ce4a")
|
||||
|
@ -30,7 +32,7 @@ async def test_rainmachine_pro_8_setup(hass):
|
|||
# Assert that the friendly name is detected correctly
|
||||
assert state.attributes["friendly_name"] == "RainMachine-00ce4a"
|
||||
|
||||
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.manufacturer == "Green Electronics LLC"
|
||||
|
|
|
@ -5,6 +5,7 @@ https://github.com/home-assistant/core/issues/26180
|
|||
"""
|
||||
|
||||
from homeassistant.components.fan import SUPPORT_DIRECTION, SUPPORT_SET_SPEED
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
|
@ -18,7 +19,7 @@ async def test_simpleconnect_fan_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "simpleconnect_fan.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Check that the fan is correctly found and set up
|
||||
fan_id = "fan.simpleconnect_fan_06f674"
|
||||
|
@ -40,7 +41,7 @@ async def test_simpleconnect_fan_setup(hass):
|
|||
SUPPORT_DIRECTION | SUPPORT_SET_SPEED
|
||||
)
|
||||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
device = device_registry.async_get(fan.device_id)
|
||||
assert device.manufacturer == "Hunter Fan"
|
||||
|
|
|
@ -9,6 +9,7 @@ from homeassistant.components.cover import (
|
|||
SUPPORT_OPEN,
|
||||
SUPPORT_SET_POSITION,
|
||||
)
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
|
@ -22,7 +23,7 @@ async def test_simpleconnect_cover_setup(hass):
|
|||
accessories = await setup_accessories_from_file(hass, "velux_gateway.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
# Check that the cover is correctly found and set up
|
||||
cover_id = "cover.velux_window"
|
||||
|
@ -64,7 +65,7 @@ async def test_simpleconnect_cover_setup(hass):
|
|||
# The cover and sensor are different devices (accessories) attached to the same bridge
|
||||
assert cover.device_id != sensor.device_id
|
||||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
device_registry = dr.async_get(hass)
|
||||
|
||||
device = device_registry.async_get(cover.device_id)
|
||||
assert device.manufacturer == "VELUX"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue