Raise ConfigEntryAuthFailed during setup or coordinator update to start reauth (#48962)
This commit is contained in:
parent
7cc857a298
commit
4cd7f9bd8b
51 changed files with 534 additions and 517 deletions
|
@ -1,8 +1,9 @@
|
|||
"""Tests for the Abode module."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from abodepy.exceptions import AbodeAuthenticationException
|
||||
from abodepy.exceptions import AbodeAuthenticationException, AbodeException
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.abode import (
|
||||
DOMAIN as ABODE_DOMAIN,
|
||||
SERVICE_CAPTURE_IMAGE,
|
||||
|
@ -10,6 +11,7 @@ from homeassistant.components.abode import (
|
|||
SERVICE_TRIGGER_AUTOMATION,
|
||||
)
|
||||
from homeassistant.components.alarm_control_panel import DOMAIN as ALARM_DOMAIN
|
||||
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY
|
||||
from homeassistant.const import CONF_USERNAME, HTTP_BAD_REQUEST
|
||||
|
||||
from .common import setup_platform
|
||||
|
@ -68,8 +70,23 @@ async def test_invalid_credentials(hass):
|
|||
"homeassistant.components.abode.Abode",
|
||||
side_effect=AbodeAuthenticationException((HTTP_BAD_REQUEST, "auth error")),
|
||||
), patch(
|
||||
"homeassistant.components.abode.config_flow.AbodeFlowHandler.async_step_reauth"
|
||||
"homeassistant.components.abode.config_flow.AbodeFlowHandler.async_step_reauth",
|
||||
return_value={"type": data_entry_flow.RESULT_TYPE_FORM},
|
||||
) as mock_async_step_reauth:
|
||||
await setup_platform(hass, ALARM_DOMAIN)
|
||||
|
||||
mock_async_step_reauth.assert_called_once()
|
||||
|
||||
|
||||
async def test_raise_config_entry_not_ready_when_offline(hass):
|
||||
"""Config entry state is ENTRY_STATE_SETUP_RETRY when abode is offline."""
|
||||
with patch(
|
||||
"homeassistant.components.abode.Abode",
|
||||
side_effect=AbodeException("any"),
|
||||
):
|
||||
config_entry = await setup_platform(hass, ALARM_DOMAIN)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert config_entry.state == ENTRY_STATE_SETUP_RETRY
|
||||
|
||||
assert hass.config_entries.flow.async_progress() == []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue