Rename cloud's AlexaConfig to CloudAlexaConfig (#64065)
* Rename cloud's AlexaConfig to CloudAlexaConfig * Tweakpull/64110/head
parent
3763407046
commit
537dfbca18
|
@ -34,7 +34,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
SYNC_DELAY = 1
|
||||
|
||||
|
||||
class AlexaConfig(alexa_config.AbstractConfig):
|
||||
class CloudAlexaConfig(alexa_config.AbstractConfig):
|
||||
"""Alexa Configuration."""
|
||||
|
||||
def __init__(
|
||||
|
|
|
@ -43,7 +43,7 @@ class CloudClient(Interface):
|
|||
self._websession = websession
|
||||
self.google_user_config = google_user_config
|
||||
self.alexa_user_config = alexa_user_config
|
||||
self._alexa_config: alexa_config.AlexaConfig | None = None
|
||||
self._alexa_config: alexa_config.CloudAlexaConfig | None = None
|
||||
self._google_config: google_config.CloudGoogleConfig | None = None
|
||||
|
||||
@property
|
||||
|
@ -82,14 +82,14 @@ class CloudClient(Interface):
|
|||
"""Return true if we want start a remote connection."""
|
||||
return self._prefs.remote_enabled
|
||||
|
||||
async def get_alexa_config(self) -> alexa_config.AlexaConfig:
|
||||
async def get_alexa_config(self) -> alexa_config.CloudAlexaConfig:
|
||||
"""Return Alexa config."""
|
||||
if self._alexa_config is None:
|
||||
assert self.cloud is not None
|
||||
|
||||
cloud_user = await self._prefs.get_cloud_user()
|
||||
|
||||
self._alexa_config = alexa_config.AlexaConfig(
|
||||
self._alexa_config = alexa_config.CloudAlexaConfig(
|
||||
self._hass, self.alexa_user_config, cloud_user, self._prefs, self.cloud
|
||||
)
|
||||
await self._alexa_config.async_initialize()
|
||||
|
|
|
@ -50,7 +50,7 @@ async def test_alexa_config_expose_entity_prefs(hass, cloud_prefs, cloud_stub):
|
|||
alexa_default_expose=["light"],
|
||||
alexa_enabled=True,
|
||||
)
|
||||
conf = alexa_config.AlexaConfig(
|
||||
conf = alexa_config.CloudAlexaConfig(
|
||||
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
|
||||
)
|
||||
await conf.async_initialize()
|
||||
|
@ -85,7 +85,7 @@ async def test_alexa_config_expose_entity_prefs(hass, cloud_prefs, cloud_stub):
|
|||
|
||||
async def test_alexa_config_report_state(hass, cloud_prefs, cloud_stub):
|
||||
"""Test Alexa config should expose using prefs."""
|
||||
conf = alexa_config.AlexaConfig(
|
||||
conf = alexa_config.CloudAlexaConfig(
|
||||
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
|
||||
)
|
||||
await conf.async_initialize()
|
||||
|
@ -120,7 +120,7 @@ async def test_alexa_config_invalidate_token(hass, cloud_prefs, aioclient_mock):
|
|||
"expires_in": 30,
|
||||
},
|
||||
)
|
||||
conf = alexa_config.AlexaConfig(
|
||||
conf = alexa_config.CloudAlexaConfig(
|
||||
hass,
|
||||
ALEXA_SCHEMA({}),
|
||||
"mock-user-id",
|
||||
|
@ -162,7 +162,7 @@ def patch_sync_helper():
|
|||
return True
|
||||
|
||||
with patch("homeassistant.components.cloud.alexa_config.SYNC_DELAY", 0), patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig._sync_helper",
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig._sync_helper",
|
||||
side_effect=sync_helper,
|
||||
):
|
||||
yield to_update, to_remove
|
||||
|
@ -170,7 +170,7 @@ def patch_sync_helper():
|
|||
|
||||
async def test_alexa_update_expose_trigger_sync(hass, cloud_prefs, cloud_stub):
|
||||
"""Test Alexa config responds to updating exposed entities."""
|
||||
await alexa_config.AlexaConfig(
|
||||
await alexa_config.CloudAlexaConfig(
|
||||
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
|
||||
).async_initialize()
|
||||
|
||||
|
@ -205,7 +205,7 @@ async def test_alexa_update_expose_trigger_sync(hass, cloud_prefs, cloud_stub):
|
|||
|
||||
async def test_alexa_entity_registry_sync(hass, mock_cloud_login, cloud_prefs):
|
||||
"""Test Alexa config responds to entity registry."""
|
||||
await alexa_config.AlexaConfig(
|
||||
await alexa_config.CloudAlexaConfig(
|
||||
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data["cloud"]
|
||||
).async_initialize()
|
||||
|
||||
|
@ -257,14 +257,14 @@ async def test_alexa_entity_registry_sync(hass, mock_cloud_login, cloud_prefs):
|
|||
|
||||
async def test_alexa_update_report_state(hass, cloud_prefs, cloud_stub):
|
||||
"""Test Alexa config responds to reporting state."""
|
||||
await alexa_config.AlexaConfig(
|
||||
await alexa_config.CloudAlexaConfig(
|
||||
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
|
||||
).async_initialize()
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig.async_sync_entities",
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.async_sync_entities",
|
||||
) as mock_sync, patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig.async_enable_proactive_mode",
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.async_enable_proactive_mode",
|
||||
):
|
||||
await cloud_prefs.async_update(alexa_report_state=True)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -278,7 +278,7 @@ def test_enabled_requires_valid_sub(hass, mock_expired_cloud_login, cloud_prefs)
|
|||
assert hass.data["cloud"].is_logged_in
|
||||
assert hass.data["cloud"].subscription_expired
|
||||
|
||||
config = alexa_config.AlexaConfig(
|
||||
config = alexa_config.CloudAlexaConfig(
|
||||
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data["cloud"]
|
||||
)
|
||||
|
||||
|
@ -287,7 +287,7 @@ def test_enabled_requires_valid_sub(hass, mock_expired_cloud_login, cloud_prefs)
|
|||
|
||||
async def test_alexa_handle_logout(hass, cloud_prefs, cloud_stub):
|
||||
"""Test Alexa config responds to logging out."""
|
||||
aconf = alexa_config.AlexaConfig(
|
||||
aconf = alexa_config.CloudAlexaConfig(
|
||||
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
|
||||
)
|
||||
|
||||
|
|
|
@ -517,10 +517,10 @@ async def test_websocket_update_preferences_alexa_report_state(
|
|||
client = await hass_ws_client(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||
".async_get_access_token",
|
||||
), patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig.set_authorized"
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.set_authorized"
|
||||
) as set_authorized_mock:
|
||||
set_authorized_mock.assert_not_called()
|
||||
await client.send_json(
|
||||
|
@ -539,11 +539,11 @@ async def test_websocket_update_preferences_require_relink(
|
|||
client = await hass_ws_client(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||
".async_get_access_token",
|
||||
side_effect=alexa_errors.RequireRelink,
|
||||
), patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig.set_authorized"
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.set_authorized"
|
||||
) as set_authorized_mock:
|
||||
set_authorized_mock.assert_not_called()
|
||||
await client.send_json(
|
||||
|
@ -563,11 +563,11 @@ async def test_websocket_update_preferences_no_token(
|
|||
client = await hass_ws_client(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||
".async_get_access_token",
|
||||
side_effect=alexa_errors.NoTokenAvailable,
|
||||
), patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig.set_authorized"
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.set_authorized"
|
||||
) as set_authorized_mock:
|
||||
set_authorized_mock.assert_not_called()
|
||||
await client.send_json(
|
||||
|
@ -769,7 +769,7 @@ async def test_sync_alexa_entities_timeout(
|
|||
"""Test that timeout syncing Alexa entities."""
|
||||
client = await hass_ws_client(hass)
|
||||
with patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||
".async_sync_entities",
|
||||
side_effect=asyncio.TimeoutError,
|
||||
):
|
||||
|
@ -786,7 +786,7 @@ async def test_sync_alexa_entities_no_token(
|
|||
"""Test sync Alexa entities when we have no token."""
|
||||
client = await hass_ws_client(hass)
|
||||
with patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||
".async_sync_entities",
|
||||
side_effect=alexa_errors.NoTokenAvailable,
|
||||
):
|
||||
|
@ -803,7 +803,7 @@ async def test_enable_alexa_state_report_fail(
|
|||
"""Test enable Alexa entities state reporting when no token available."""
|
||||
client = await hass_ws_client(hass)
|
||||
with patch(
|
||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
||||
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||
".async_sync_entities",
|
||||
side_effect=alexa_errors.NoTokenAvailable,
|
||||
):
|
||||
|
|
Loading…
Reference in New Issue