Remove old import logic for waze_travel_time (#80079)
Remove old import logic
This commit is contained in:
parent
6826f2c291
commit
d01f85b6aa
2 changed files with 2 additions and 34 deletions
|
@ -2,24 +2,13 @@
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_registry import (
|
||||
async_entries_for_config_entry,
|
||||
async_get,
|
||||
)
|
||||
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
||||
"""Load the saved entities."""
|
||||
if entry.unique_id is not None:
|
||||
hass.config_entries.async_update_entry(entry, unique_id=None)
|
||||
|
||||
ent_reg = async_get(hass)
|
||||
for entity in async_entries_for_config_entry(ent_reg, entry.entry_id):
|
||||
ent_reg.async_update_entity(entity.entity_id, new_unique_id=entry.entry_id)
|
||||
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
"""Test Waze Travel Time initialization."""
|
||||
from homeassistant.components.waze_travel_time.const import DOMAIN
|
||||
from homeassistant.helpers.entity_registry import async_get
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_migration(hass, bypass_platform_setup):
|
||||
"""Test migration logic for unique id."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN, version=1, entry_id="test", unique_id="test"
|
||||
)
|
||||
ent_reg = async_get(hass)
|
||||
ent_entry = ent_reg.async_get_or_create(
|
||||
"sensor", DOMAIN, unique_id="replaceable_unique_id", config_entry=config_entry
|
||||
)
|
||||
entity_id = ent_entry.entity_id
|
||||
config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
assert config_entry.unique_id is None
|
||||
assert ent_reg.async_get(entity_id).unique_id == config_entry.entry_id
|
Loading…
Add table
Add a link
Reference in a new issue