From 02dffcde1a74de113734d30eed96d6c236d00718 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 2 Jul 2024 12:36:30 +0200 Subject: [PATCH] Use common registry fixtures in solarlog (#121005) --- tests/components/solarlog/conftest.py | 20 +------------------- tests/components/solarlog/test_init.py | 10 ++++++---- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/tests/components/solarlog/conftest.py b/tests/components/solarlog/conftest.py index 86cdc870cde..c34d0c011a3 100644 --- a/tests/components/solarlog/conftest.py +++ b/tests/components/solarlog/conftest.py @@ -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) diff --git a/tests/components/solarlog/test_init.py b/tests/components/solarlog/test_init.py index f9f00ef601b..0044d09f20e 100644 --- a/tests/components/solarlog/test_init.py +++ b/tests/components/solarlog/test_init.py @@ -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"