Convert august to be push instead of poll (#47544)
This commit is contained in:
parent
8e4c0e3ff7
commit
a2c4b438ea
21 changed files with 683 additions and 183 deletions
|
@ -3,13 +3,14 @@ import asyncio
|
|||
from unittest.mock import patch
|
||||
|
||||
from aiohttp import ClientResponseError
|
||||
from august.authenticator_common import AuthenticationState
|
||||
from august.exceptions import AugustApiAIOHTTPError
|
||||
from yalexs.authenticator_common import AuthenticationState
|
||||
from yalexs.exceptions import AugustApiAIOHTTPError
|
||||
|
||||
from homeassistant import setup
|
||||
from homeassistant.components.august.const import DOMAIN
|
||||
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
|
@ -46,7 +47,7 @@ async def test_august_is_offline(hass):
|
|||
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
with patch(
|
||||
"august.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
side_effect=asyncio.TimeoutError,
|
||||
):
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
@ -152,7 +153,7 @@ async def test_auth_fails(hass):
|
|||
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
with patch(
|
||||
"august.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
side_effect=ClientResponseError(None, None, status=401),
|
||||
):
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
@ -178,7 +179,7 @@ async def test_bad_password(hass):
|
|||
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
with patch(
|
||||
"august.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
return_value=_mock_august_authentication(
|
||||
"original_token", 1234, AuthenticationState.BAD_PASSWORD
|
||||
),
|
||||
|
@ -206,7 +207,7 @@ async def test_http_failure(hass):
|
|||
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
with patch(
|
||||
"august.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
side_effect=ClientResponseError(None, None, status=500),
|
||||
):
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
@ -230,7 +231,7 @@ async def test_unknown_auth_state(hass):
|
|||
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
with patch(
|
||||
"august.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
return_value=_mock_august_authentication("original_token", 1234, None),
|
||||
):
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
@ -256,7 +257,7 @@ async def test_requires_validation_state(hass):
|
|||
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
with patch(
|
||||
"august.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||
return_value=_mock_august_authentication(
|
||||
"original_token", 1234, AuthenticationState.REQUIRES_VALIDATION
|
||||
),
|
||||
|
@ -268,3 +269,18 @@ async def test_requires_validation_state(hass):
|
|||
|
||||
assert len(hass.config_entries.flow.async_progress()) == 1
|
||||
assert hass.config_entries.flow.async_progress()[0]["context"]["source"] == "reauth"
|
||||
|
||||
|
||||
async def test_load_unload(hass):
|
||||
"""Config entry can be unloaded."""
|
||||
|
||||
august_operative_lock = await _mock_operative_august_lock_detail(hass)
|
||||
august_inoperative_lock = await _mock_inoperative_august_lock_detail(hass)
|
||||
config_entry = await _create_august_with_devices(
|
||||
hass, [august_operative_lock, august_inoperative_lock]
|
||||
)
|
||||
|
||||
assert config_entry.state == ENTRY_STATE_LOADED
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue