mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Use device registry mock instead of hass.helpers
in dsmr tests (#114535)
This commit is contained in:
parent
05d40fbc4c
commit
0238c2ea9e
@ -6,13 +6,16 @@ from decimal import Decimal
|
|||||||
from homeassistant.components.dsmr.const import DOMAIN
|
from homeassistant.components.dsmr.const import DOMAIN
|
||||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
async def test_migrate_gas_to_mbus(
|
async def test_migrate_gas_to_mbus(
|
||||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, dsmr_connection_fixture
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
dsmr_connection_fixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test migration of unique_id."""
|
"""Test migration of unique_id."""
|
||||||
(connection_factory, transport, protocol) = dsmr_connection_fixture
|
(connection_factory, transport, protocol) = dsmr_connection_fixture
|
||||||
@ -42,7 +45,6 @@ async def test_migrate_gas_to_mbus(
|
|||||||
|
|
||||||
old_unique_id = "37464C4F32313139303333373331_belgium_5min_gas_meter_reading"
|
old_unique_id = "37464C4F32313139303333373331_belgium_5min_gas_meter_reading"
|
||||||
|
|
||||||
device_registry = hass.helpers.device_registry.async_get(hass)
|
|
||||||
device = device_registry.async_get_or_create(
|
device = device_registry.async_get_or_create(
|
||||||
config_entry_id=mock_entry.entry_id,
|
config_entry_id=mock_entry.entry_id,
|
||||||
identifiers={(DOMAIN, mock_entry.entry_id)},
|
identifiers={(DOMAIN, mock_entry.entry_id)},
|
||||||
@ -108,7 +110,10 @@ async def test_migrate_gas_to_mbus(
|
|||||||
|
|
||||||
|
|
||||||
async def test_migrate_gas_to_mbus_exists(
|
async def test_migrate_gas_to_mbus_exists(
|
||||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, dsmr_connection_fixture
|
hass: HomeAssistant,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
dsmr_connection_fixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test migration of unique_id."""
|
"""Test migration of unique_id."""
|
||||||
(connection_factory, transport, protocol) = dsmr_connection_fixture
|
(connection_factory, transport, protocol) = dsmr_connection_fixture
|
||||||
@ -138,7 +143,6 @@ async def test_migrate_gas_to_mbus_exists(
|
|||||||
|
|
||||||
old_unique_id = "37464C4F32313139303333373331_belgium_5min_gas_meter_reading"
|
old_unique_id = "37464C4F32313139303333373331_belgium_5min_gas_meter_reading"
|
||||||
|
|
||||||
device_registry = hass.helpers.device_registry.async_get(hass)
|
|
||||||
device = device_registry.async_get_or_create(
|
device = device_registry.async_get_or_create(
|
||||||
config_entry_id=mock_entry.entry_id,
|
config_entry_id=mock_entry.entry_id,
|
||||||
identifiers={(DOMAIN, mock_entry.entry_id)},
|
identifiers={(DOMAIN, mock_entry.entry_id)},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user