Clean up accessing entity_registry.async_get_registry helper via hass (#72005)

This commit is contained in:
Franck Nijhof 2022-05-17 16:40:45 +02:00 committed by GitHub
parent c7b4aca998
commit 69cc6ab5f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 89 additions and 82 deletions

View file

@ -2,14 +2,15 @@
from homeassistant.components.plex.const import DOMAIN
from homeassistant.const import Platform
from homeassistant.helpers import device_registry as dr, entity_registry as er
async def test_cleanup_orphaned_devices(hass, entry, setup_plex_server):
"""Test cleaning up orphaned devices on startup."""
test_device_id = {(DOMAIN, "temporary_device_123")}
device_registry = await hass.helpers.device_registry.async_get_registry()
entity_registry = await hass.helpers.entity_registry.async_get_registry()
device_registry = dr.async_get(hass)
entity_registry = er.async_get(hass)
test_device = device_registry.async_get_or_create(
config_entry_id=entry.entry_id,
@ -44,8 +45,8 @@ async def test_migrate_transient_devices(
non_plexweb_device_id = {(DOMAIN, "1234567890123456-com-plexapp-android")}
plex_client_service_device_id = {(DOMAIN, "plex.tv-clients")}
device_registry = await hass.helpers.device_registry.async_get_registry()
entity_registry = await hass.helpers.entity_registry.async_get_registry()
device_registry = dr.async_get(hass)
entity_registry = er.async_get(hass)
# Pre-create devices and entities to test device migration
plexweb_device = device_registry.async_get_or_create(