* Add test for invalid usercode * Add usercodes to totalconnect. * Update existing tests for usercodes * Fix tests * Add test for invalid usercode * Add usercodes to totalconnect. * Update existing tests for usercodes * Fix tests * Remove YAML support * Fix conflict * Bump to total_connect_client 0.56 * Change Exception to HomeAssistantError * Fix config_flow.py * Simplify async_setup since no yaml * Remove import from config flow and tests * Add reauth and test for it. Various other fixes. * Fix pylint in __init__ * Show config yaml as deprecated * separate config_flow and init tests * Assert ENTRY_STATE_SETUP_ERROR in init test * Add test for reauth flow * Fix reauth and tests * Fix strings * Restore username and usercode with new passord * Correct the integration name * Update tests/components/totalconnect/test_config_flow.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update tests/components/totalconnect/test_init.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update .coveragerc * Add test for invalid auth during reauth * Bump total-connect-client to 0.57 * Fix .coveragerc * More tests for usercodes * Fix usercode test * Reload config entry on reauth Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
29 lines
947 B
Python
29 lines
947 B
Python
"""Tests for the TotalConnect init process."""
|
|
from unittest.mock import patch
|
|
|
|
from homeassistant.components.totalconnect.const import DOMAIN
|
|
from homeassistant.config_entries import ENTRY_STATE_SETUP_ERROR
|
|
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.TotalConnectClient",
|
|
autospec=True,
|
|
) as mock_client:
|
|
mock_client.return_value.is_valid_credentials.return_value = False
|
|
assert await async_setup_component(hass, DOMAIN, {})
|
|
await hass.async_block_till_done()
|
|
|
|
assert mock_entry.state == ENTRY_STATE_SETUP_ERROR
|