mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Use HassKey in cloud integration (#120322)
This commit is contained in:
@@ -8,6 +8,7 @@ import pytest
|
||||
|
||||
from homeassistant.components.cloud import GACTIONS_SCHEMA
|
||||
from homeassistant.components.cloud.const import (
|
||||
DATA_CLOUD,
|
||||
PREF_DISABLE_2FA,
|
||||
PREF_GOOGLE_DEFAULT_EXPOSE,
|
||||
PREF_GOOGLE_ENTITY_CONFIGS,
|
||||
@@ -196,7 +197,7 @@ async def test_google_entity_registry_sync(
|
||||
expose_new(hass, True)
|
||||
|
||||
config = CloudGoogleConfig(
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data["cloud"]
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data[DATA_CLOUD]
|
||||
)
|
||||
await config.async_initialize()
|
||||
await config.async_connect_agent_user("mock-user-id")
|
||||
@@ -264,7 +265,7 @@ async def test_google_device_registry_sync(
|
||||
) -> None:
|
||||
"""Test Google config responds to device registry."""
|
||||
config = CloudGoogleConfig(
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data["cloud"]
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data[DATA_CLOUD]
|
||||
)
|
||||
|
||||
# Enable exposing new entities to Google
|
||||
@@ -333,7 +334,7 @@ async def test_sync_google_when_started(
|
||||
) -> None:
|
||||
"""Test Google config syncs on init."""
|
||||
config = CloudGoogleConfig(
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data["cloud"]
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data[DATA_CLOUD]
|
||||
)
|
||||
with patch.object(config, "async_sync_entities_all") as mock_sync:
|
||||
await config.async_initialize()
|
||||
@@ -346,7 +347,7 @@ async def test_sync_google_on_home_assistant_start(
|
||||
) -> None:
|
||||
"""Test Google config syncs when home assistant started."""
|
||||
config = CloudGoogleConfig(
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data["cloud"]
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data[DATA_CLOUD]
|
||||
)
|
||||
hass.set_state(CoreState.not_running)
|
||||
with patch.object(config, "async_sync_entities_all") as mock_sync:
|
||||
@@ -441,11 +442,11 @@ def test_enabled_requires_valid_sub(
|
||||
) -> None:
|
||||
"""Test that google config enabled requires a valid Cloud sub."""
|
||||
assert cloud_prefs.google_enabled
|
||||
assert hass.data["cloud"].is_logged_in
|
||||
assert hass.data["cloud"].subscription_expired
|
||||
assert hass.data[DATA_CLOUD].is_logged_in
|
||||
assert hass.data[DATA_CLOUD].subscription_expired
|
||||
|
||||
config = CloudGoogleConfig(
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data["cloud"]
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data[DATA_CLOUD]
|
||||
)
|
||||
|
||||
assert not config.enabled
|
||||
@@ -494,7 +495,7 @@ async def test_google_handle_logout(
|
||||
await cloud_prefs.get_cloud_user()
|
||||
|
||||
with patch.object(
|
||||
hass.data["cloud"].auth,
|
||||
hass.data[DATA_CLOUD].auth,
|
||||
"async_check_token",
|
||||
side_effect=AssertionError("Should not be called"),
|
||||
):
|
||||
@@ -857,7 +858,7 @@ async def test_google_config_get_agent_user_id(
|
||||
) -> None:
|
||||
"""Test overridden get_agent_user_id_from_webhook method."""
|
||||
config = CloudGoogleConfig(
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data["cloud"]
|
||||
hass, GACTIONS_SCHEMA({}), "mock-user-id", cloud_prefs, hass.data[DATA_CLOUD]
|
||||
)
|
||||
assert (
|
||||
config.get_agent_user_id_from_webhook(cloud_prefs.google_local_webhook_id)
|
||||
|
||||
Reference in New Issue
Block a user