hass-core/tests/components/totalconnect/test_init.py
Ville Skyttä 19d25cd901
Change config entry state to an enum ()
* Change config entry state to an enum

* Allow but deprecate EntryState str equality comparison

* Test fixes

* Rename to ConfigEntryState

* Remove str comparability backcompat

* Update new occurrences of strs cropped up during review
2021-05-20 19:19:20 +02:00

29 lines
945 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 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.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 is ConfigEntryState.SETUP_ERROR