Adjust homekit controller pairing to have a new step for each potentially recoverable error (#38742)

* Adjust homekit controller pairing errors back to a single step

* adjust test

* Revert "Adjust homekit controller pairing errors back to a single step"

This reverts commit e5ed89bbbb053bb814219052ae99697a5a7b4e46.

* Revert "adjust test"

This reverts commit c2e9f21a8401c144315260f6fdf71ea8060f8ca3.

* adjust

* prune

* prune

* merge

* Update tests

* remove debug

* adjust

* Multiple steps

* adjust the test
This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-08-14 10:34:52 -05:00
1 parent 4ecdb1f19f
commit 483d09b9c1
4 files changed
+88 -54

No files matched your search

@@ -334,19 +334,21 @@ async def test_pair_try_later_errors_on_start(hass, controller, exception, expec
test_exc = exception("error")
with patch.object(device, "start_pairing", side_effect=test_exc):
result2 = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result2["step_id"] == "try_pair_later"
assert result2["step_id"] == expected
assert result2["type"] == "form"
assert result2["errors"]["base"] == expected
# Device is rebooted or placed into pairing mode as they have been instructed
# We start pairing again
result3 = await hass.config_entries.flow.async_configure(result2["flow_id"])
result3 = await hass.config_entries.flow.async_configure(
result2["flow_id"], user_input={"any": "key"}
)
# .. and successfully complete pair
result4 = await hass.config_entries.flow.async_configure(
result3["flow_id"], user_input={"pairing_code": "111-22-333"}
)
assert result4["type"] == "create_entry"
assert result4["title"] == "Koogeek-LS1-20833F"
@@ -373,7 +375,9 @@ async def test_pair_form_errors_on_start(hass, controller, exception, expected):
# User initiates pairing - device refuses to enter pairing mode
test_exc = exception("error")
with patch.object(device, "start_pairing", side_effect=test_exc):
result = await hass.config_entries.flow.async_configure(result["flow_id"])
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"pairing_code": "111-22-333"}
)
assert result["type"] == "form"
assert result["errors"]["pairing_code"] == expected
@@ -384,10 +388,16 @@ async def test_pair_form_errors_on_start(hass, controller, exception, expected):
"source": "zeroconf",
}
# User gets back the form
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == "form"
assert result["errors"] == {}
# User re-tries entering pairing code
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"pairing_code": "111-22-333"}
)
assert result["type"] == "create_entry"
assert result["title"] == "Koogeek-LS1-20833F"