Clean up accessing device_registry helpers via hass (#72031)

This commit is contained in:
Franck Nijhof 2022-05-17 21:22:15 +02:00 committed by GitHub
parent 69e622b327
commit c3d19f3827
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 105 additions and 87 deletions

View file

@ -17,8 +17,7 @@ from homeassistant.const import (
STATE_UNAVAILABLE,
STATE_UNKNOWN,
)
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.util import dt
from tests.common import (
@ -497,13 +496,13 @@ class TestPicnicSensor(unittest.IsolatedAsyncioTestCase):
# Setup platform and default mock responses
await self._setup_platform(use_default_responses=True)
device_registry = await self.hass.helpers.device_registry.async_get_registry()
device_registry = dr.async_get(self.hass)
picnic_service = device_registry.async_get_device(
identifiers={(const.DOMAIN, DEFAULT_USER_RESPONSE["user_id"])}
)
assert picnic_service.model == DEFAULT_USER_RESPONSE["user_id"]
assert picnic_service.name == "Picnic: Commonstreet 123a"
assert picnic_service.entry_type is DeviceEntryType.SERVICE
assert picnic_service.entry_type is dr.DeviceEntryType.SERVICE
async def test_auth_token_is_saved_on_update(self):
"""Test that auth-token changes in the session object are reflected by the config entry."""