Use `async_update_entry` in config unit test instead of modifying `data` (#55855)

pull/55876/head
puddly 2021-09-06 16:57:59 -04:00 committed by GitHub
parent 34d54511e8
commit 6895081595
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -184,7 +184,7 @@ async def async_migrate_entry(
data[CONF_DEVICE][CONF_BAUDRATE] = baudrate
config_entry.version = 2
config_entry.data = data
hass.config_entries.async_update_entry(config_entry, data=data)
if config_entry.version == 2:
data = {**config_entry.data}
@ -193,7 +193,7 @@ async def async_migrate_entry(
data[CONF_RADIO_TYPE] = "znp"
config_entry.version = 3
config_entry.data = data
hass.config_entries.async_update_entry(config_entry, data=data)
_LOGGER.info("Migration to version %s successful", config_entry.version)
return True

View File

@ -13,7 +13,7 @@ from homeassistant.components.ssdp import (
ATTR_UPNP_MANUFACTURER_URL,
ATTR_UPNP_SERIAL,
)
from homeassistant.components.zha import async_migrate_entry, config_flow
from homeassistant.components.zha import config_flow
from homeassistant.components.zha.core.const import (
CONF_BAUDRATE,
CONF_FLOWCONTROL,
@ -633,8 +633,6 @@ async def test_user_port_config(probe_mock, hass):
)
async def test_migration_ti_cc_to_znp(old_type, new_type, hass, config_entry):
"""Test zigpy-cc to zigpy-znp config migration."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN,
unique_id=old_type + new_type,
@ -651,7 +649,9 @@ async def test_migration_ti_cc_to_znp(old_type, new_type, hass, config_entry):
config_entry.version = 2
config_entry.add_to_hass(hass)
await async_migrate_entry(hass, config_entry)
with patch("homeassistant.components.zha.async_setup_entry", return_value=True):
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
assert config_entry.version > 2
assert config_entry.data[CONF_RADIO_TYPE] == new_type