Use FlowResultType enum in config flow tests A-M (#114681)
This commit is contained in:
parent
a767530970
commit
b9281327c4
111 changed files with 997 additions and 961 deletions
|
@ -243,7 +243,7 @@ async def test_discovery_works(
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair"
|
||||
assert get_flow_context(hass, result) == {
|
||||
"source": config_entries.SOURCE_ZEROCONF,
|
||||
|
@ -253,14 +253,14 @@ async def test_discovery_works(
|
|||
|
||||
# User initiates pairing - device enters pairing mode and displays code
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair"
|
||||
|
||||
# Pairing doesn't error error and pairing results
|
||||
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["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Koogeek-LS1-20833F"
|
||||
assert result["data"] == {}
|
||||
|
||||
|
@ -276,7 +276,7 @@ async def test_abort_duplicate_flow(hass: HomeAssistant, controller) -> None:
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -284,7 +284,7 @@ async def test_abort_duplicate_flow(hass: HomeAssistant, controller) -> None:
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
|
@ -300,7 +300,7 @@ async def test_pair_already_paired_1(hass: HomeAssistant, controller) -> None:
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_paired"
|
||||
|
||||
|
||||
|
@ -317,7 +317,7 @@ async def test_unknown_domain_type(hass: HomeAssistant, controller) -> None:
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "ignored_model"
|
||||
|
||||
|
||||
|
@ -335,7 +335,7 @@ async def test_id_missing(hass: HomeAssistant, controller) -> None:
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "invalid_properties"
|
||||
|
||||
|
||||
|
@ -352,7 +352,7 @@ async def test_discovery_ignored_model(hass: HomeAssistant, controller) -> None:
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "ignored_model"
|
||||
|
||||
|
||||
|
@ -380,7 +380,7 @@ async def test_discovery_ignored_hk_bridge(
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "ignored_model"
|
||||
|
||||
|
||||
|
@ -408,7 +408,7 @@ async def test_discovery_does_not_ignore_non_homekit(
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
|
||||
async def test_discovery_broken_pairing_flag(hass: HomeAssistant, controller) -> None:
|
||||
|
@ -483,7 +483,7 @@ async def test_discovery_invalid_config_entry(hass: HomeAssistant, controller) -
|
|||
assert config_entry_count == 0
|
||||
|
||||
# And new config flow should continue allowing user to set up a new pairing
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
|
||||
async def test_discovery_ignored_config_entry(hass: HomeAssistant, controller) -> None:
|
||||
|
@ -549,7 +549,7 @@ async def test_discovery_already_configured(hass: HomeAssistant, controller) ->
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data["AccessoryIP"] == discovery_info.host
|
||||
assert entry.data["AccessoryPort"] == discovery_info.port
|
||||
|
@ -587,7 +587,7 @@ async def test_discovery_already_configured_update_csharp(
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -615,7 +615,7 @@ async def test_pair_abort_errors_on_start(
|
|||
test_exc = exception("error")
|
||||
with patch.object(device, "async_start_pairing", side_effect=test_exc):
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == expected
|
||||
|
||||
|
||||
|
@ -640,7 +640,7 @@ async def test_pair_try_later_errors_on_start(
|
|||
with patch.object(device, "async_start_pairing", side_effect=test_exc):
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result2["step_id"] == expected
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
|
||||
# Device is rebooted or placed into pairing mode as they have been instructed
|
||||
|
||||
|
@ -654,7 +654,7 @@ async def test_pair_try_later_errors_on_start(
|
|||
result3["flow_id"], user_input={"pairing_code": "111-22-333"}
|
||||
)
|
||||
|
||||
assert result4["type"] == "create_entry"
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == "Koogeek-LS1-20833F"
|
||||
|
||||
|
||||
|
@ -686,7 +686,7 @@ async def test_pair_form_errors_on_start(
|
|||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"pairing_code": "111-22-333"}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"]["pairing_code"] == expected
|
||||
|
||||
assert get_flow_context(hass, result) == {
|
||||
|
@ -697,7 +697,7 @@ async def test_pair_form_errors_on_start(
|
|||
|
||||
# User gets back the form
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
# User re-tries entering pairing code
|
||||
|
@ -705,7 +705,7 @@ async def test_pair_form_errors_on_start(
|
|||
result["flow_id"], user_input={"pairing_code": "111-22-333"}
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Koogeek-LS1-20833F"
|
||||
|
||||
|
||||
|
@ -736,7 +736,7 @@ async def test_pair_abort_errors_on_finish(
|
|||
with patch.object(device, "async_start_pairing", return_value=finish_pairing):
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert get_flow_context(hass, result) == {
|
||||
"title_placeholders": {"name": "TestDevice", "category": "Outlet"},
|
||||
"unique_id": "00:00:00:00:00:00",
|
||||
|
@ -747,7 +747,7 @@ async def test_pair_abort_errors_on_finish(
|
|||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"pairing_code": "111-22-333"}
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == expected
|
||||
|
||||
|
||||
|
@ -778,7 +778,7 @@ async def test_pair_form_errors_on_finish(
|
|||
with patch.object(device, "async_start_pairing", return_value=finish_pairing):
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert get_flow_context(hass, result) == {
|
||||
"title_placeholders": {"name": "TestDevice", "category": "Outlet"},
|
||||
"unique_id": "00:00:00:00:00:00",
|
||||
|
@ -789,7 +789,7 @@ async def test_pair_form_errors_on_finish(
|
|||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"pairing_code": "111-22-333"}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"]["pairing_code"] == expected
|
||||
|
||||
assert get_flow_context(hass, result) == {
|
||||
|
@ -826,7 +826,7 @@ async def test_pair_unknown_errors(hass: HomeAssistant, controller) -> None:
|
|||
with patch.object(device, "async_start_pairing", return_value=finish_pairing):
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert get_flow_context(hass, result) == {
|
||||
"title_placeholders": {"name": "TestDevice", "category": "Outlet"},
|
||||
"unique_id": "00:00:00:00:00:00",
|
||||
|
@ -837,7 +837,7 @@ async def test_pair_unknown_errors(hass: HomeAssistant, controller) -> None:
|
|||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"pairing_code": "111-22-333"}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"]["pairing_code"] == "pairing_failed"
|
||||
assert (
|
||||
result["description_placeholders"]["error"] == "The bluetooth connection failed"
|
||||
|
@ -860,7 +860,7 @@ async def test_user_works(hass: HomeAssistant, controller) -> None:
|
|||
"homekit_controller", context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert get_flow_context(hass, result) == {
|
||||
"source": config_entries.SOURCE_USER,
|
||||
|
@ -869,7 +869,7 @@ async def test_user_works(hass: HomeAssistant, controller) -> None:
|
|||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"device": "TestDevice"}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair"
|
||||
|
||||
assert get_flow_context(hass, result) == {
|
||||
|
@ -881,7 +881,7 @@ async def test_user_works(hass: HomeAssistant, controller) -> None:
|
|||
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["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Koogeek-LS1-20833F"
|
||||
|
||||
|
||||
|
@ -897,7 +897,7 @@ async def test_user_pairing_with_insecure_setup_code(
|
|||
"homekit_controller", context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert get_flow_context(hass, result) == {
|
||||
"source": config_entries.SOURCE_USER,
|
||||
|
@ -906,7 +906,7 @@ async def test_user_pairing_with_insecure_setup_code(
|
|||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"device": "TestDevice"}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair"
|
||||
|
||||
assert get_flow_context(hass, result) == {
|
||||
|
@ -918,7 +918,7 @@ async def test_user_pairing_with_insecure_setup_code(
|
|||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"pairing_code": "123-45-678"}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair"
|
||||
assert result["errors"] == {"pairing_code": "insecure_setup_code"}
|
||||
|
||||
|
@ -926,7 +926,7 @@ async def test_user_pairing_with_insecure_setup_code(
|
|||
result["flow_id"],
|
||||
user_input={"pairing_code": "123-45-678", "allow_insecure_setup_codes": True},
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Koogeek-LS1-20833F"
|
||||
|
||||
|
||||
|
@ -935,7 +935,7 @@ async def test_user_no_devices(hass: HomeAssistant, controller) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
"homekit_controller", context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_devices"
|
||||
|
||||
|
||||
|
@ -952,7 +952,7 @@ async def test_user_no_unpaired_devices(hass: HomeAssistant, controller) -> None
|
|||
"homekit_controller", context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_devices"
|
||||
|
||||
|
||||
|
@ -966,7 +966,7 @@ async def test_unignore_works(hass: HomeAssistant, controller) -> None:
|
|||
context={"source": config_entries.SOURCE_UNIGNORE},
|
||||
data={"unique_id": device.description.id},
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair"
|
||||
assert get_flow_context(hass, result) == {
|
||||
"title_placeholders": {"name": "TestDevice", "category": "Other"},
|
||||
|
@ -976,14 +976,14 @@ async def test_unignore_works(hass: HomeAssistant, controller) -> None:
|
|||
|
||||
# User initiates pairing by clicking on 'configure' - device enters pairing mode and displays code
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair"
|
||||
|
||||
# Pairing finalized
|
||||
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["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Koogeek-LS1-20833F"
|
||||
|
||||
|
||||
|
@ -1000,7 +1000,7 @@ async def test_unignore_ignores_missing_devices(
|
|||
data={"unique_id": "00:00:00:00:00:01"},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "accessory_not_found_error"
|
||||
|
||||
|
||||
|
@ -1022,7 +1022,7 @@ async def test_discovery_dismiss_existing_flow_on_paired(
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair"
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
|
@ -1038,7 +1038,7 @@ async def test_discovery_dismiss_existing_flow_on_paired(
|
|||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_paired"
|
||||
await hass.async_block_till_done()
|
||||
assert (
|
||||
|
@ -1088,7 +1088,7 @@ async def test_mdns_update_to_paired_during_pairing(
|
|||
with patch.object(device, "async_start_pairing", _async_start_pairing):
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert get_flow_context(hass, result) == {
|
||||
"title_placeholders": {"name": "TestDevice", "category": "Outlet"},
|
||||
"unique_id": "00:00:00:00:00:00",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue