mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use common registry fixtures in tplink (#121002)
This commit is contained in:
parent
9ca9377cad
commit
71b7ee40e5
@ -20,7 +20,7 @@ from . import (
|
|||||||
_mocked_device,
|
_mocked_device,
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import MockConfigEntry, mock_device_registry, mock_registry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -72,18 +72,6 @@ def mock_connect():
|
|||||||
yield {"connect": mock_connect, "mock_devices": devices}
|
yield {"connect": mock_connect, "mock_devices": devices}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="device_reg")
|
|
||||||
def device_reg_fixture(hass):
|
|
||||||
"""Return an empty, loaded, registry."""
|
|
||||||
return mock_device_registry(hass)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="entity_reg")
|
|
||||||
def entity_reg_fixture(hass):
|
|
||||||
"""Return an empty, loaded, registry."""
|
|
||||||
return mock_registry(hass)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
|
@ -107,7 +107,7 @@ async def test_config_entry_retry(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def test_dimmer_switch_unique_id_fix_original_entity_still_exists(
|
async def test_dimmer_switch_unique_id_fix_original_entity_still_exists(
|
||||||
hass: HomeAssistant, entity_reg: er.EntityRegistry
|
hass: HomeAssistant, entity_registry: er.EntityRegistry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test no migration happens if the original entity id still exists."""
|
"""Test no migration happens if the original entity id still exists."""
|
||||||
config_entry = MockConfigEntry(domain=DOMAIN, data={}, unique_id=MAC_ADDRESS)
|
config_entry = MockConfigEntry(domain=DOMAIN, data={}, unique_id=MAC_ADDRESS)
|
||||||
@ -115,14 +115,14 @@ async def test_dimmer_switch_unique_id_fix_original_entity_still_exists(
|
|||||||
dimmer = _mocked_device(alias="My dimmer", modules=[Module.Light])
|
dimmer = _mocked_device(alias="My dimmer", modules=[Module.Light])
|
||||||
rollout_unique_id = MAC_ADDRESS.replace(":", "").upper()
|
rollout_unique_id = MAC_ADDRESS.replace(":", "").upper()
|
||||||
original_unique_id = tplink.legacy_device_id(dimmer)
|
original_unique_id = tplink.legacy_device_id(dimmer)
|
||||||
original_dimmer_entity_reg = entity_reg.async_get_or_create(
|
original_dimmer_entity_reg = entity_registry.async_get_or_create(
|
||||||
config_entry=config_entry,
|
config_entry=config_entry,
|
||||||
platform=DOMAIN,
|
platform=DOMAIN,
|
||||||
domain="light",
|
domain="light",
|
||||||
unique_id=original_unique_id,
|
unique_id=original_unique_id,
|
||||||
original_name="Original dimmer",
|
original_name="Original dimmer",
|
||||||
)
|
)
|
||||||
rollout_dimmer_entity_reg = entity_reg.async_get_or_create(
|
rollout_dimmer_entity_reg = entity_registry.async_get_or_create(
|
||||||
config_entry=config_entry,
|
config_entry=config_entry,
|
||||||
platform=DOMAIN,
|
platform=DOMAIN,
|
||||||
domain="light",
|
domain="light",
|
||||||
@ -138,7 +138,7 @@ async def test_dimmer_switch_unique_id_fix_original_entity_still_exists(
|
|||||||
await setup.async_setup_component(hass, DOMAIN, {})
|
await setup.async_setup_component(hass, DOMAIN, {})
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
|
|
||||||
migrated_dimmer_entity_reg = entity_reg.async_get_or_create(
|
migrated_dimmer_entity_reg = entity_registry.async_get_or_create(
|
||||||
config_entry=config_entry,
|
config_entry=config_entry,
|
||||||
platform=DOMAIN,
|
platform=DOMAIN,
|
||||||
domain="light",
|
domain="light",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user