Dedup and clarify imported konnected config flows (#32138)
* dedup config flows * use default (imported) options until user goes thru options flow * address pr feedback * correct key used to distinguish pro model
This commit is contained in:
parent
438c4acf07
commit
5488389244
7 changed files with 478 additions and 181 deletions
|
@ -34,7 +34,7 @@ async def test_flow_works(hass, mock_panel):
|
|||
|
||||
mock_panel.get_status.return_value = {
|
||||
"mac": "11:22:33:44:55:66",
|
||||
"name": "Konnected",
|
||||
"model": "Konnected",
|
||||
}
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"port": 1234, "host": "1.2.3.4"}
|
||||
|
@ -43,6 +43,7 @@ async def test_flow_works(hass, mock_panel):
|
|||
assert result["step_id"] == "confirm"
|
||||
assert result["description_placeholders"] == {
|
||||
"model": "Konnected Alarm Panel",
|
||||
"id": "112233445566",
|
||||
"host": "1.2.3.4",
|
||||
"port": 1234,
|
||||
}
|
||||
|
@ -70,7 +71,7 @@ async def test_pro_flow_works(hass, mock_panel):
|
|||
|
||||
mock_panel.get_status.return_value = {
|
||||
"mac": "11:22:33:44:55:66",
|
||||
"name": "Konnected Pro",
|
||||
"model": "Konnected Pro",
|
||||
}
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"port": 1234, "host": "1.2.3.4"}
|
||||
|
@ -79,6 +80,7 @@ async def test_pro_flow_works(hass, mock_panel):
|
|||
assert result["step_id"] == "confirm"
|
||||
assert result["description_placeholders"] == {
|
||||
"model": "Konnected Alarm Panel Pro",
|
||||
"id": "112233445566",
|
||||
"host": "1.2.3.4",
|
||||
"port": 1234,
|
||||
}
|
||||
|
@ -100,7 +102,7 @@ async def test_ssdp(hass, mock_panel):
|
|||
"""Test a panel being discovered."""
|
||||
mock_panel.get_status.return_value = {
|
||||
"mac": "11:22:33:44:55:66",
|
||||
"name": "Konnected",
|
||||
"model": "Konnected",
|
||||
}
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -117,6 +119,7 @@ async def test_ssdp(hass, mock_panel):
|
|||
assert result["step_id"] == "confirm"
|
||||
assert result["description_placeholders"] == {
|
||||
"model": "Konnected Alarm Panel",
|
||||
"id": "112233445566",
|
||||
"host": "1.2.3.4",
|
||||
"port": 1234,
|
||||
}
|
||||
|
@ -125,8 +128,8 @@ async def test_ssdp(hass, mock_panel):
|
|||
async def test_import_no_host_user_finish(hass, mock_panel):
|
||||
"""Test importing a panel with no host info."""
|
||||
mock_panel.get_status.return_value = {
|
||||
"mac": "11:22:33:44:55:66",
|
||||
"name": "Konnected Pro",
|
||||
"mac": "aa:bb:cc:dd:ee:ff",
|
||||
"model": "Konnected Pro",
|
||||
}
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -159,6 +162,13 @@ async def test_import_no_host_user_finish(hass, mock_panel):
|
|||
},
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "import_confirm"
|
||||
assert result["description_placeholders"]["id"] == "aabbccddeeff"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# confirm user is prompted to enter host
|
||||
|
@ -169,6 +179,7 @@ async def test_import_no_host_user_finish(hass, mock_panel):
|
|||
assert result["step_id"] == "confirm"
|
||||
assert result["description_placeholders"] == {
|
||||
"model": "Konnected Alarm Panel Pro",
|
||||
"id": "aabbccddeeff",
|
||||
"host": "1.1.1.1",
|
||||
"port": 1234,
|
||||
}
|
||||
|
@ -180,6 +191,78 @@ async def test_import_no_host_user_finish(hass, mock_panel):
|
|||
assert result["type"] == "create_entry"
|
||||
|
||||
|
||||
async def test_import_ssdp_host_user_finish(hass, mock_panel):
|
||||
"""Test importing a panel with no host info which ssdp discovers."""
|
||||
mock_panel.get_status.return_value = {
|
||||
"mac": "11:22:33:44:55:66",
|
||||
"model": "Konnected Pro",
|
||||
}
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN,
|
||||
context={"source": "import"},
|
||||
data={
|
||||
"default_options": {
|
||||
"blink": True,
|
||||
"discovery": True,
|
||||
"io": {
|
||||
"1": "Disabled",
|
||||
"10": "Disabled",
|
||||
"11": "Disabled",
|
||||
"12": "Disabled",
|
||||
"2": "Disabled",
|
||||
"3": "Disabled",
|
||||
"4": "Disabled",
|
||||
"5": "Disabled",
|
||||
"6": "Disabled",
|
||||
"7": "Disabled",
|
||||
"8": "Disabled",
|
||||
"9": "Disabled",
|
||||
"alarm1": "Disabled",
|
||||
"alarm2_out2": "Disabled",
|
||||
"out": "Disabled",
|
||||
"out1": "Disabled",
|
||||
},
|
||||
},
|
||||
"id": "112233445566",
|
||||
},
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "import_confirm"
|
||||
assert result["description_placeholders"]["id"] == "112233445566"
|
||||
|
||||
# discover the panel via ssdp
|
||||
ssdp_result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN,
|
||||
context={"source": "ssdp"},
|
||||
data={
|
||||
"ssdp_location": "http://0.0.0.0:1234/Device.xml",
|
||||
"manufacturer": config_flow.KONN_MANUFACTURER,
|
||||
"modelName": config_flow.KONN_MODEL_PRO,
|
||||
},
|
||||
)
|
||||
assert ssdp_result["type"] == "abort"
|
||||
assert ssdp_result["reason"] == "already_in_progress"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "confirm"
|
||||
assert result["description_placeholders"] == {
|
||||
"model": "Konnected Alarm Panel Pro",
|
||||
"id": "112233445566",
|
||||
"host": "0.0.0.0",
|
||||
"port": 1234,
|
||||
}
|
||||
|
||||
# final confirmation
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
|
||||
|
||||
async def test_ssdp_already_configured(hass, mock_panel):
|
||||
"""Test if a discovered panel has already been configured."""
|
||||
MockConfigEntry(
|
||||
|
@ -189,7 +272,7 @@ async def test_ssdp_already_configured(hass, mock_panel):
|
|||
).add_to_hass(hass)
|
||||
mock_panel.get_status.return_value = {
|
||||
"mac": "11:22:33:44:55:66",
|
||||
"name": "Konnected Pro",
|
||||
"model": "Konnected Pro",
|
||||
}
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -265,7 +348,7 @@ async def test_ssdp_host_update(hass, mock_panel):
|
|||
).add_to_hass(hass)
|
||||
mock_panel.get_status.return_value = {
|
||||
"mac": "11:22:33:44:55:66",
|
||||
"name": "Konnected Pro",
|
||||
"model": "Konnected Pro",
|
||||
}
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -289,7 +372,7 @@ async def test_import_existing_config(hass, mock_panel):
|
|||
"""Test importing a host with an existing config file."""
|
||||
mock_panel.get_status.return_value = {
|
||||
"mac": "11:22:33:44:55:66",
|
||||
"name": "Konnected Pro",
|
||||
"model": "Konnected Pro",
|
||||
}
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -402,7 +485,7 @@ async def test_import_existing_config_entry(hass, mock_panel):
|
|||
|
||||
mock_panel.get_status.return_value = {
|
||||
"mac": "11:22:33:44:55:66",
|
||||
"name": "Konnected Pro",
|
||||
"model": "Konnected Pro",
|
||||
}
|
||||
|
||||
# utilize a global access token this time
|
||||
|
@ -462,7 +545,7 @@ async def test_import_pin_config(hass, mock_panel):
|
|||
"""Test importing a host with an existing config file that specifies pin configs."""
|
||||
mock_panel.get_status.return_value = {
|
||||
"mac": "11:22:33:44:55:66",
|
||||
"name": "Konnected Pro",
|
||||
"model": "Konnected Pro",
|
||||
}
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue