mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +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.components.solarlog.const import DOMAIN as SOLARLOG_DOMAIN
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
|
||||||
|
|
||||||
from .const import HOST, NAME
|
from .const import HOST, NAME
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import MockConfigEntry, load_json_object_fixture
|
||||||
MockConfigEntry,
|
|
||||||
load_json_object_fixture,
|
|
||||||
mock_device_registry,
|
|
||||||
mock_registry,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -76,15 +70,3 @@ def mock_test_connection():
|
|||||||
return_value=True,
|
return_value=True,
|
||||||
):
|
):
|
||||||
yield
|
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(
|
async def test_migrate_config_entry(
|
||||||
hass: HomeAssistant, device_reg: DeviceRegistry, entity_reg: EntityRegistry
|
hass: HomeAssistant,
|
||||||
|
device_registry: DeviceRegistry,
|
||||||
|
entity_registry: EntityRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test successful migration of entry data."""
|
"""Test successful migration of entry data."""
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
@ -64,13 +66,13 @@ async def test_migrate_config_entry(
|
|||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
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,
|
config_entry_id=entry.entry_id,
|
||||||
identifiers={(DOMAIN, entry.entry_id)},
|
identifiers={(DOMAIN, entry.entry_id)},
|
||||||
manufacturer="Solar-Log",
|
manufacturer="Solar-Log",
|
||||||
name="solarlog",
|
name="solarlog",
|
||||||
)
|
)
|
||||||
sensor_entity = entity_reg.async_get_or_create(
|
sensor_entity = entity_registry.async_get_or_create(
|
||||||
config_entry=entry,
|
config_entry=entry,
|
||||||
platform=DOMAIN,
|
platform=DOMAIN,
|
||||||
domain=Platform.SENSOR,
|
domain=Platform.SENSOR,
|
||||||
@ -85,7 +87,7 @@ async def test_migrate_config_entry(
|
|||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
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
|
||||||
assert entity_migrated.unique_id == f"{entry.entry_id}_last_updated"
|
assert entity_migrated.unique_id == f"{entry.entry_id}_last_updated"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user