Rename cloud's AlexaConfig to CloudAlexaConfig (#64065)
* Rename cloud's AlexaConfig to CloudAlexaConfig * Tweak
This commit is contained in:
parent
3763407046
commit
537dfbca18
4 changed files with 24 additions and 24 deletions
|
@ -34,7 +34,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||||
SYNC_DELAY = 1
|
SYNC_DELAY = 1
|
||||||
|
|
||||||
|
|
||||||
class AlexaConfig(alexa_config.AbstractConfig):
|
class CloudAlexaConfig(alexa_config.AbstractConfig):
|
||||||
"""Alexa Configuration."""
|
"""Alexa Configuration."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
|
@ -43,7 +43,7 @@ class CloudClient(Interface):
|
||||||
self._websession = websession
|
self._websession = websession
|
||||||
self.google_user_config = google_user_config
|
self.google_user_config = google_user_config
|
||||||
self.alexa_user_config = alexa_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
|
self._google_config: google_config.CloudGoogleConfig | None = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -82,14 +82,14 @@ class CloudClient(Interface):
|
||||||
"""Return true if we want start a remote connection."""
|
"""Return true if we want start a remote connection."""
|
||||||
return self._prefs.remote_enabled
|
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."""
|
"""Return Alexa config."""
|
||||||
if self._alexa_config is None:
|
if self._alexa_config is None:
|
||||||
assert self.cloud is not None
|
assert self.cloud is not None
|
||||||
|
|
||||||
cloud_user = await self._prefs.get_cloud_user()
|
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
|
self._hass, self.alexa_user_config, cloud_user, self._prefs, self.cloud
|
||||||
)
|
)
|
||||||
await self._alexa_config.async_initialize()
|
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_default_expose=["light"],
|
||||||
alexa_enabled=True,
|
alexa_enabled=True,
|
||||||
)
|
)
|
||||||
conf = alexa_config.AlexaConfig(
|
conf = alexa_config.CloudAlexaConfig(
|
||||||
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
|
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
|
||||||
)
|
)
|
||||||
await conf.async_initialize()
|
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):
|
async def test_alexa_config_report_state(hass, cloud_prefs, cloud_stub):
|
||||||
"""Test Alexa config should expose using prefs."""
|
"""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
|
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
|
||||||
)
|
)
|
||||||
await conf.async_initialize()
|
await conf.async_initialize()
|
||||||
|
@ -120,7 +120,7 @@ async def test_alexa_config_invalidate_token(hass, cloud_prefs, aioclient_mock):
|
||||||
"expires_in": 30,
|
"expires_in": 30,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
conf = alexa_config.AlexaConfig(
|
conf = alexa_config.CloudAlexaConfig(
|
||||||
hass,
|
hass,
|
||||||
ALEXA_SCHEMA({}),
|
ALEXA_SCHEMA({}),
|
||||||
"mock-user-id",
|
"mock-user-id",
|
||||||
|
@ -162,7 +162,7 @@ def patch_sync_helper():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
with patch("homeassistant.components.cloud.alexa_config.SYNC_DELAY", 0), patch(
|
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,
|
side_effect=sync_helper,
|
||||||
):
|
):
|
||||||
yield to_update, to_remove
|
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):
|
async def test_alexa_update_expose_trigger_sync(hass, cloud_prefs, cloud_stub):
|
||||||
"""Test Alexa config responds to updating exposed entities."""
|
"""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
|
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
|
||||||
).async_initialize()
|
).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):
|
async def test_alexa_entity_registry_sync(hass, mock_cloud_login, cloud_prefs):
|
||||||
"""Test Alexa config responds to entity registry."""
|
"""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"]
|
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data["cloud"]
|
||||||
).async_initialize()
|
).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):
|
async def test_alexa_update_report_state(hass, cloud_prefs, cloud_stub):
|
||||||
"""Test Alexa config responds to reporting state."""
|
"""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
|
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_prefs, cloud_stub
|
||||||
).async_initialize()
|
).async_initialize()
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.cloud.alexa_config.AlexaConfig.async_sync_entities",
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.async_sync_entities",
|
||||||
) as mock_sync, patch(
|
) 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 cloud_prefs.async_update(alexa_report_state=True)
|
||||||
await hass.async_block_till_done()
|
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"].is_logged_in
|
||||||
assert hass.data["cloud"].subscription_expired
|
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"]
|
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):
|
async def test_alexa_handle_logout(hass, cloud_prefs, cloud_stub):
|
||||||
"""Test Alexa config responds to logging out."""
|
"""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
|
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)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||||
".async_get_access_token",
|
".async_get_access_token",
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.cloud.alexa_config.AlexaConfig.set_authorized"
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.set_authorized"
|
||||||
) as set_authorized_mock:
|
) as set_authorized_mock:
|
||||||
set_authorized_mock.assert_not_called()
|
set_authorized_mock.assert_not_called()
|
||||||
await client.send_json(
|
await client.send_json(
|
||||||
|
@ -539,11 +539,11 @@ async def test_websocket_update_preferences_require_relink(
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||||
".async_get_access_token",
|
".async_get_access_token",
|
||||||
side_effect=alexa_errors.RequireRelink,
|
side_effect=alexa_errors.RequireRelink,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.cloud.alexa_config.AlexaConfig.set_authorized"
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.set_authorized"
|
||||||
) as set_authorized_mock:
|
) as set_authorized_mock:
|
||||||
set_authorized_mock.assert_not_called()
|
set_authorized_mock.assert_not_called()
|
||||||
await client.send_json(
|
await client.send_json(
|
||||||
|
@ -563,11 +563,11 @@ async def test_websocket_update_preferences_no_token(
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||||
".async_get_access_token",
|
".async_get_access_token",
|
||||||
side_effect=alexa_errors.NoTokenAvailable,
|
side_effect=alexa_errors.NoTokenAvailable,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.cloud.alexa_config.AlexaConfig.set_authorized"
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.set_authorized"
|
||||||
) as set_authorized_mock:
|
) as set_authorized_mock:
|
||||||
set_authorized_mock.assert_not_called()
|
set_authorized_mock.assert_not_called()
|
||||||
await client.send_json(
|
await client.send_json(
|
||||||
|
@ -769,7 +769,7 @@ async def test_sync_alexa_entities_timeout(
|
||||||
"""Test that timeout syncing Alexa entities."""
|
"""Test that timeout syncing Alexa entities."""
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||||
".async_sync_entities",
|
".async_sync_entities",
|
||||||
side_effect=asyncio.TimeoutError,
|
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."""
|
"""Test sync Alexa entities when we have no token."""
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||||
".async_sync_entities",
|
".async_sync_entities",
|
||||||
side_effect=alexa_errors.NoTokenAvailable,
|
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."""
|
"""Test enable Alexa entities state reporting when no token available."""
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.cloud.alexa_config.AlexaConfig"
|
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
|
||||||
".async_sync_entities",
|
".async_sync_entities",
|
||||||
side_effect=alexa_errors.NoTokenAvailable,
|
side_effect=alexa_errors.NoTokenAvailable,
|
||||||
):
|
):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue