Fix zwave_js config flow import step (#56808)

This commit is contained in:
Martin Hjelmare 2021-09-30 01:15:05 +02:00 committed by GitHub
parent b9d81c3a7e
commit 12b2076351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 4 deletions

View File

@ -321,8 +321,10 @@ class ConfigFlow(BaseZwaveJSFlow, config_entries.ConfigFlow, domain=DOMAIN):
This step will be used when importing data This step will be used when importing data
during Z-Wave to Z-Wave JS migration. during Z-Wave to Z-Wave JS migration.
""" """
self.network_key = data.get(CONF_NETWORK_KEY) # Note that the data comes from the zwave integration.
self.usb_path = data.get(CONF_USB_PATH) # So we don't use our constants here.
self.s0_legacy_key = data.get("network_key")
self.usb_path = data.get("usb_path")
return await self.async_step_user() return await self.async_step_user()
async def async_step_user( async def async_step_user(

View File

@ -2422,6 +2422,14 @@ async def test_import_addon_installed(
# the default input should be the imported data # the default input should be the imported data
default_input = result["data_schema"]({}) default_input = result["data_schema"]({})
assert default_input == {
"usb_path": "/test/imported",
"s0_legacy_key": "imported123",
"s2_access_control_key": "",
"s2_authenticated_key": "",
"s2_unauthenticated_key": "",
}
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], default_input result["flow_id"], default_input
) )
@ -2429,7 +2437,15 @@ async def test_import_addon_installed(
assert set_addon_options.call_args == call( assert set_addon_options.call_args == call(
hass, hass,
"core_zwave_js", "core_zwave_js",
{"options": {"device": "/test/imported", "network_key": "imported123"}}, {
"options": {
"device": "/test/imported",
"s0_legacy_key": "imported123",
"s2_access_control_key": "",
"s2_authenticated_key": "",
"s2_unauthenticated_key": "",
}
},
) )
assert result["type"] == "progress" assert result["type"] == "progress"
@ -2452,7 +2468,10 @@ async def test_import_addon_installed(
assert result["data"] == { assert result["data"] == {
"url": "ws://host1:3001", "url": "ws://host1:3001",
"usb_path": "/test/imported", "usb_path": "/test/imported",
"network_key": "imported123", "s0_legacy_key": "imported123",
"s2_access_control_key": "",
"s2_authenticated_key": "",
"s2_unauthenticated_key": "",
"use_addon": True, "use_addon": True,
"integration_created_addon": False, "integration_created_addon": False,
} }