Type hint device registry identifiers as set of str 2-tuples (#50355)

* Type hint device registry identifiers as set of str 2-tuples

* Fix airly test

* Really fix airly test, add another migration test
This commit is contained in:
Ville Skyttä 2021-05-10 13:13:45 +03:00 committed by GitHub
parent 1c98df5d18
commit b89c53f759
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 39 additions and 27 deletions

View file

@ -1,6 +1,8 @@
"""Test init of Airly integration."""
from unittest.mock import patch
import pytest
from homeassistant.components.airly import set_update_interval
from homeassistant.components.airly.const import DOMAIN
from homeassistant.config_entries import (
@ -188,7 +190,8 @@ async def test_unload_entry(hass, aioclient_mock):
assert not hass.data.get(DOMAIN)
async def test_migrate_device_entry(hass, aioclient_mock):
@pytest.mark.parametrize("old_identifier", ((DOMAIN, 123, 456), (DOMAIN, "123", "456")))
async def test_migrate_device_entry(hass, aioclient_mock, old_identifier):
"""Test device_info identifiers migration."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@ -207,13 +210,13 @@ async def test_migrate_device_entry(hass, aioclient_mock):
device_reg = mock_device_registry(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id, identifiers={(DOMAIN, 123, 456)}
config_entry_id=config_entry.entry_id, identifiers={old_identifier}
)
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
migrated_device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id, identifiers={(DOMAIN, "123", "456")}
config_entry_id=config_entry.entry_id, identifiers={(DOMAIN, "123-456")}
)
assert device_entry.id == migrated_device_entry.id