Update f-g* tests to use entity & device registry fixtures (#103841)

This commit is contained in:
Jan-Philipp Benecke 2023-11-12 13:07:38 +01:00 committed by GitHub
parent b9bc6ca070
commit 04a497343d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 317 additions and 270 deletions

View file

@ -61,16 +61,18 @@ async def test_sensor_states(hass: HomeAssistant) -> None:
],
)
async def test_migrate_unique_id(
hass: HomeAssistant, object_id: str, old_unique_id: str, new_unique_id: str
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
object_id: str,
old_unique_id: str,
new_unique_id: str,
) -> None:
"""Test unique id migration."""
old_config_data = {**MOCK_USER_INPUT, "name": "Glances"}
entry = MockConfigEntry(domain=DOMAIN, data=old_config_data)
entry.add_to_hass(hass)
ent_reg = er.async_get(hass)
entity: er.RegistryEntry = ent_reg.async_get_or_create(
entity: er.RegistryEntry = entity_registry.async_get_or_create(
suggested_object_id=object_id,
disabled_by=None,
domain=SENSOR_DOMAIN,
@ -83,6 +85,6 @@ async def test_migrate_unique_id(
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
entity_migrated = ent_reg.async_get(entity.entity_id)
entity_migrated = entity_registry.async_get(entity.entity_id)
assert entity_migrated
assert entity_migrated.unique_id == f"{entry.entry_id}-{new_unique_id}"