* update total_connect_client to 2021.10 * update for total_connect_client changes * remove unused return value * bump total_connect_client to 2021.11.1 * bump total_connect_client to 2021.11.2 * Move to public ResultCode * load locations to prevent 'unknown error occurred' * add test for zero locations * put error message in strings * test for abort and message from strings * handle AuthenticationError in step_user * update tests with exceptions * update reauth with exceptions * use try except else per suggestion * only create schema if necessary * catch auth error in async_setup_entry * one more fix in test_init
30 lines
949 B
Python
30 lines
949 B
Python
"""Tests for the TotalConnect init process."""
|
|
from unittest.mock import patch
|
|
|
|
from total_connect_client.exceptions import AuthenticationError
|
|
|
|
from homeassistant.components.totalconnect.const import DOMAIN
|
|
from homeassistant.config_entries import ConfigEntryState
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
from .common import CONFIG_DATA
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
async def test_reauth_started(hass):
|
|
"""Test that reauth is started when we have login errors."""
|
|
mock_entry = MockConfigEntry(
|
|
domain=DOMAIN,
|
|
data=CONFIG_DATA,
|
|
)
|
|
mock_entry.add_to_hass(hass)
|
|
|
|
with patch(
|
|
"homeassistant.components.totalconnect.TotalConnectClient",
|
|
) as mock_client:
|
|
mock_client.side_effect = AuthenticationError()
|
|
assert await async_setup_component(hass, DOMAIN, {})
|
|
await hass.async_block_till_done()
|
|
|
|
assert mock_entry.state is ConfigEntryState.SETUP_ERROR
|