Add missing SimpliSafe config flow test (#58563)
This commit is contained in:
parent
f619a8e4a0
commit
806242093d
1 changed files with 39 additions and 0 deletions
|
@ -180,6 +180,45 @@ async def test_step_reauth_new_format(hass, mock_async_from_auth):
|
|||
assert config_entry.data == {CONF_USER_ID: "12345", CONF_TOKEN: "token123"}
|
||||
|
||||
|
||||
async def test_step_reauth_wrong_account(hass, api, mock_async_from_auth):
|
||||
"""Test the re-auth step returning a different account from this one."""
|
||||
MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id="12345",
|
||||
data={
|
||||
CONF_USER_ID: "12345",
|
||||
CONF_TOKEN: "token123",
|
||||
},
|
||||
).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_REAUTH},
|
||||
data={CONF_USER_ID: "12345", CONF_TOKEN: "token123"},
|
||||
)
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# Simulate the next auth call returning a different user ID than the one we've
|
||||
# identified as this entry's unique ID:
|
||||
api.user_id = "67890"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.simplisafe.async_setup_entry", return_value=True
|
||||
), patch("homeassistant.config_entries.ConfigEntries.async_reload"):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
)
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={CONF_AUTH_CODE: "code123"}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "wrong_account"
|
||||
|
||||
assert len(hass.config_entries.async_entries()) == 1
|
||||
[config_entry] = hass.config_entries.async_entries(DOMAIN)
|
||||
assert config_entry.unique_id == "12345"
|
||||
|
||||
|
||||
async def test_step_user(hass, mock_async_from_auth):
|
||||
"""Test the user step."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
|
Loading…
Add table
Reference in a new issue