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
during Z-Wave to Z-Wave JS migration.
"""
self.network_key = data.get(CONF_NETWORK_KEY)
self.usb_path = data.get(CONF_USB_PATH)
# Note that the data comes from the zwave integration.
# 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()
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
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["flow_id"], default_input
)
@ -2429,7 +2437,15 @@ async def test_import_addon_installed(
assert set_addon_options.call_args == call(
hass,
"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"
@ -2452,7 +2468,10 @@ async def test_import_addon_installed(
assert result["data"] == {
"url": "ws://host1:3001",
"usb_path": "/test/imported",
"network_key": "imported123",
"s0_legacy_key": "imported123",
"s2_access_control_key": "",
"s2_authenticated_key": "",
"s2_unauthenticated_key": "",
"use_addon": True,
"integration_created_addon": False,
}