Increase test coverage for Total Connect (#116851)
Increase test coverage Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
This commit is contained in:
parent
b4ec1f5877
commit
3498cb3ced
1 changed files with 28 additions and 1 deletions
|
@ -5,7 +5,11 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from syrupy import SnapshotAssertion
|
from syrupy import SnapshotAssertion
|
||||||
from total_connect_client.exceptions import ServiceUnavailable, TotalConnectError
|
from total_connect_client.exceptions import (
|
||||||
|
AuthenticationError,
|
||||||
|
ServiceUnavailable,
|
||||||
|
TotalConnectError,
|
||||||
|
)
|
||||||
|
|
||||||
from homeassistant.components.alarm_control_panel import DOMAIN as ALARM_DOMAIN
|
from homeassistant.components.alarm_control_panel import DOMAIN as ALARM_DOMAIN
|
||||||
from homeassistant.components.totalconnect.alarm_control_panel import (
|
from homeassistant.components.totalconnect.alarm_control_panel import (
|
||||||
|
@ -14,6 +18,7 @@ from homeassistant.components.totalconnect.alarm_control_panel import (
|
||||||
)
|
)
|
||||||
from homeassistant.components.totalconnect.const import DOMAIN
|
from homeassistant.components.totalconnect.const import DOMAIN
|
||||||
from homeassistant.components.totalconnect.coordinator import SCAN_INTERVAL
|
from homeassistant.components.totalconnect.coordinator import SCAN_INTERVAL
|
||||||
|
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
SERVICE_ALARM_ARM_AWAY,
|
SERVICE_ALARM_ARM_AWAY,
|
||||||
|
@ -567,3 +572,25 @@ async def test_other_update_failures(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
assert hass.states.get(ENTITY_ID).state == STATE_UNAVAILABLE
|
assert hass.states.get(ENTITY_ID).state == STATE_UNAVAILABLE
|
||||||
assert mock_request.call_count == 6
|
assert mock_request.call_count == 6
|
||||||
|
|
||||||
|
|
||||||
|
async def test_authentication_error(hass: HomeAssistant) -> None:
|
||||||
|
"""Test other failures seen during updates."""
|
||||||
|
entry = await setup_platform(hass, ALARM_DOMAIN)
|
||||||
|
|
||||||
|
with patch(TOTALCONNECT_REQUEST, side_effect=AuthenticationError):
|
||||||
|
await async_update_entity(hass, ENTITY_ID)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert entry.state is ConfigEntryState.LOADED
|
||||||
|
|
||||||
|
flows = hass.config_entries.flow.async_progress()
|
||||||
|
assert len(flows) == 1
|
||||||
|
|
||||||
|
flow = flows[0]
|
||||||
|
assert flow.get("step_id") == "reauth_confirm"
|
||||||
|
assert flow.get("handler") == DOMAIN
|
||||||
|
|
||||||
|
assert "context" in flow
|
||||||
|
assert flow["context"].get("source") == SOURCE_REAUTH
|
||||||
|
assert flow["context"].get("entry_id") == entry.entry_id
|
||||||
|
|
Loading…
Add table
Reference in a new issue