mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Use common registry fixtures in solarlog (#121005)
This commit is contained in:
parent
cdc3897319
commit
02dffcde1a
@ -7,16 +7,10 @@ import pytest
|
||||
|
||||
from homeassistant.components.solarlog.const import DOMAIN as SOLARLOG_DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import HOST, NAME
|
||||
|
||||
from tests.common import (
|
||||
MockConfigEntry,
|
||||
load_json_object_fixture,
|
||||
mock_device_registry,
|
||||
mock_registry,
|
||||
)
|
||||
from tests.common import MockConfigEntry, load_json_object_fixture
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -76,15 +70,3 @@ def mock_test_connection():
|
||||
return_value=True,
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(name="device_reg")
|
||||
def device_reg_fixture(hass: HomeAssistant):
|
||||
"""Return an empty, loaded, registry."""
|
||||
return mock_device_registry(hass)
|
||||
|
||||
|
||||
@pytest.fixture(name="entity_reg")
|
||||
def entity_reg_fixture(hass: HomeAssistant):
|
||||
"""Return an empty, loaded, registry."""
|
||||
return mock_registry(hass)
|
||||
|
@ -50,7 +50,9 @@ async def test_raise_config_entry_not_ready_when_offline(
|
||||
|
||||
|
||||
async def test_migrate_config_entry(
|
||||
hass: HomeAssistant, device_reg: DeviceRegistry, entity_reg: EntityRegistry
|
||||
hass: HomeAssistant,
|
||||
device_registry: DeviceRegistry,
|
||||
entity_registry: EntityRegistry,
|
||||
) -> None:
|
||||
"""Test successful migration of entry data."""
|
||||
entry = MockConfigEntry(
|
||||
@ -64,13 +66,13 @@ async def test_migrate_config_entry(
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
device = device_reg.async_get_or_create(
|
||||
device = device_registry.async_get_or_create(
|
||||
config_entry_id=entry.entry_id,
|
||||
identifiers={(DOMAIN, entry.entry_id)},
|
||||
manufacturer="Solar-Log",
|
||||
name="solarlog",
|
||||
)
|
||||
sensor_entity = entity_reg.async_get_or_create(
|
||||
sensor_entity = entity_registry.async_get_or_create(
|
||||
config_entry=entry,
|
||||
platform=DOMAIN,
|
||||
domain=Platform.SENSOR,
|
||||
@ -85,7 +87,7 @@ async def test_migrate_config_entry(
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_migrated = entity_reg.async_get(sensor_entity.entity_id)
|
||||
entity_migrated = entity_registry.async_get(sensor_entity.entity_id)
|
||||
assert entity_migrated
|
||||
assert entity_migrated.unique_id == f"{entry.entry_id}_last_updated"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user