mirror of
https://github.com/home-assistant/core.git
synced 2025-09-10 07:11:37 +02:00
Fix async_migrate_entry for Alexa Devices (#151038)
This commit is contained in:
@@ -42,7 +42,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: AmazonConfigEntry) -> bo
|
|||||||
|
|
||||||
async def async_migrate_entry(hass: HomeAssistant, entry: AmazonConfigEntry) -> bool:
|
async def async_migrate_entry(hass: HomeAssistant, entry: AmazonConfigEntry) -> bool:
|
||||||
"""Migrate old entry."""
|
"""Migrate old entry."""
|
||||||
if entry.version == 1 and entry.minor_version == 0:
|
if entry.version == 1 and entry.minor_version == 1:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Migrating from version %s.%s", entry.version, entry.minor_version
|
"Migrating from version %s.%s", entry.version, entry.minor_version
|
||||||
)
|
)
|
||||||
@@ -56,12 +56,12 @@ async def async_migrate_entry(hass: HomeAssistant, entry: AmazonConfigEntry) ->
|
|||||||
new_data.update({"site": f"https://www.amazon.{domain}"})
|
new_data.update({"site": f"https://www.amazon.{domain}"})
|
||||||
|
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
entry, data=new_data, version=1, minor_version=1
|
entry, data=new_data, version=1, minor_version=2
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
"Migration to version %s.%s successful", entry.version, entry.minor_version
|
"Migration to version %s.%s successful", entry.version, entry.minor_version
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@@ -52,7 +52,7 @@ class AmazonDevicesConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle a config flow for Alexa Devices."""
|
"""Handle a config flow for Alexa Devices."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
MINOR_VERSION = 1
|
MINOR_VERSION = 2
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
@@ -85,4 +85,6 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
CONF_LOGIN_DATA: {"session": "test-session"},
|
CONF_LOGIN_DATA: {"session": "test-session"},
|
||||||
},
|
},
|
||||||
unique_id=TEST_USERNAME,
|
unique_id=TEST_USERNAME,
|
||||||
|
version=1,
|
||||||
|
minor_version=2,
|
||||||
)
|
)
|
||||||
|
@@ -57,7 +57,7 @@
|
|||||||
'discovery_keys': dict({
|
'discovery_keys': dict({
|
||||||
}),
|
}),
|
||||||
'domain': 'alexa_devices',
|
'domain': 'alexa_devices',
|
||||||
'minor_version': 1,
|
'minor_version': 2,
|
||||||
'options': dict({
|
'options': dict({
|
||||||
}),
|
}),
|
||||||
'pref_disable_new_entities': False,
|
'pref_disable_new_entities': False,
|
||||||
|
@@ -49,7 +49,7 @@ async def test_migrate_entry(
|
|||||||
},
|
},
|
||||||
unique_id=TEST_USERNAME,
|
unique_id=TEST_USERNAME,
|
||||||
version=1,
|
version=1,
|
||||||
minor_version=0,
|
minor_version=1,
|
||||||
)
|
)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
@@ -57,5 +57,5 @@ async def test_migrate_entry(
|
|||||||
|
|
||||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||||
assert config_entry.state is ConfigEntryState.LOADED
|
assert config_entry.state is ConfigEntryState.LOADED
|
||||||
assert config_entry.minor_version == 1
|
assert config_entry.minor_version == 2
|
||||||
assert config_entry.data["site"] == f"https://www.amazon.{TEST_COUNTRY}"
|
assert config_entry.data["site"] == f"https://www.amazon.{TEST_COUNTRY}"
|
||||||
|
Reference in New Issue
Block a user