Use start_reauth_flow in permobil tests (#129314)

This commit is contained in:
epenet 2024-10-28 11:51:16 +01:00 committed by GitHub
parent 2bec20ad76
commit 0216d36ab7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -284,11 +284,7 @@ async def test_config_flow_reauth_success(
"homeassistant.components.permobil.config_flow.MyPermobil",
return_value=my_permobil,
):
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
context={"source": "reauth", "entry_id": mock_entry.entry_id},
data=mock_entry.data,
)
result = await mock_entry.start_reauth_flow(hass)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "email_code"
@ -328,11 +324,7 @@ async def test_config_flow_reauth_fail_invalid_code(
"homeassistant.components.permobil.config_flow.MyPermobil",
return_value=my_permobil,
):
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
context={"source": "reauth", "entry_id": mock_entry.entry_id},
data=mock_entry.data,
)
result = await mock_entry.start_reauth_flow(hass)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "email_code"
@ -360,17 +352,11 @@ async def test_config_flow_reauth_fail_code_request(
)
mock_entry.add_to_hass(hass)
# test the reauth and have request_application_code fail leading to an abort
my_permobil.request_application_code.side_effect = MyPermobilAPIException
reauth_entry = hass.config_entries.async_entries(config_flow.DOMAIN)[0]
with patch(
"homeassistant.components.permobil.config_flow.MyPermobil",
return_value=my_permobil,
):
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
context={"source": "reauth", "entry_id": reauth_entry.entry_id},
data=mock_entry.data,
)
result = await mock_entry.start_reauth_flow(hass)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"