Upgrade to use new version of HASS-nabucasa (#30506)
* Upgrade to use new version of HASS-nabucasa * Update hass-nabucasa to 0.31
This commit is contained in:
1 parent
6dc49a44d9
commit
c963128306
10 files changed
+31
-45
No files matched your search
@@ -36,19 +36,20 @@ async def test_google_update_report_state(hass, cloud_prefs):
|
||||
|
||||
async def test_sync_entities(aioclient_mock, hass, cloud_prefs):
|
||||
"""Test sync devices."""
|
||||
aioclient_mock.post("http://example.com", status=404)
|
||||
config = CloudGoogleConfig(
|
||||
hass,
|
||||
GACTIONS_SCHEMA({}),
|
||||
"mock-user-id",
|
||||
cloud_prefs,
|
||||
Mock(
|
||||
google_actions_sync_url="http://example.com",
|
||||
auth=Mock(async_check_token=Mock(side_effect=mock_coro)),
|
||||
),
|
||||
Mock(auth=Mock(async_check_token=Mock(side_effect=mock_coro)),),
|
||||
)
|
||||
|
||||
assert await config.async_sync_entities("user") == 404
|
||||
with patch(
|
||||
"hass_nabucasa.cloud_api.async_google_actions_request_sync",
|
||||
return_value=mock_coro(Mock(status=404)),
|
||||
) as mock_request_sync:
|
||||
assert await config.async_sync_entities("user") == 404
|
||||
assert len(mock_request_sync.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_google_update_expose_trigger_sync(hass, cloud_prefs):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Tests for the HTTP API for the cloud component."""
|
||||
import asyncio
|
||||
from ipaddress import ip_network
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import MagicMock, Mock, patch
|
||||
|
||||
from hass_nabucasa import thingtalk
|
||||
from hass_nabucasa.auth import Unauthenticated, UnknownError
|
||||
@@ -21,7 +21,6 @@ from . import mock_cloud, mock_cloud_prefs
|
||||
from tests.common import mock_coro
|
||||
from tests.components.google_assistant import MockConfig
|
||||
|
||||
GOOGLE_ACTIONS_SYNC_URL = "https://api-test.hass.io/google_actions_sync"
|
||||
SUBSCRIPTION_INFO_URL = "https://api-test.hass.io/subscription_info"
|
||||
|
||||
|
||||
@@ -59,7 +58,6 @@ def setup_api(hass, aioclient_mock):
|
||||
"user_pool_id": "user_pool_id",
|
||||
"region": "region",
|
||||
"relayer": "relayer",
|
||||
"google_actions_sync_url": GOOGLE_ACTIONS_SYNC_URL,
|
||||
"subscription_info_url": SUBSCRIPTION_INFO_URL,
|
||||
"google_actions": {"filter": {"include_domains": "light"}},
|
||||
"alexa": {
|
||||
@@ -85,22 +83,26 @@ def mock_cognito():
|
||||
yield mock_cog()
|
||||
|
||||
|
||||
async def test_google_actions_sync(
|
||||
mock_cognito, mock_cloud_login, cloud_client, aioclient_mock
|
||||
):
|
||||
async def test_google_actions_sync(mock_cognito, mock_cloud_login, cloud_client):
|
||||
"""Test syncing Google Actions."""
|
||||
aioclient_mock.post(GOOGLE_ACTIONS_SYNC_URL)
|
||||
req = await cloud_client.post("/api/cloud/google_actions/sync")
|
||||
assert req.status == 200
|
||||
with patch(
|
||||
"hass_nabucasa.cloud_api.async_google_actions_request_sync",
|
||||
return_value=mock_coro(Mock(status=200)),
|
||||
) as mock_request_sync:
|
||||
req = await cloud_client.post("/api/cloud/google_actions/sync")
|
||||
assert req.status == 200
|
||||
assert len(mock_request_sync.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_google_actions_sync_fails(
|
||||
mock_cognito, mock_cloud_login, cloud_client, aioclient_mock
|
||||
):
|
||||
async def test_google_actions_sync_fails(mock_cognito, mock_cloud_login, cloud_client):
|
||||
"""Test syncing Google Actions gone bad."""
|
||||
aioclient_mock.post(GOOGLE_ACTIONS_SYNC_URL, status=403)
|
||||
req = await cloud_client.post("/api/cloud/google_actions/sync")
|
||||
assert req.status == 403
|
||||
with patch(
|
||||
"hass_nabucasa.cloud_api.async_google_actions_request_sync",
|
||||
return_value=mock_coro(Mock(status=500)),
|
||||
) as mock_request_sync:
|
||||
req = await cloud_client.post("/api/cloud/google_actions/sync")
|
||||
assert req.status == 500
|
||||
assert len(mock_request_sync.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_login_view(hass, cloud_client):
|
||||
|
||||
@@ -28,7 +28,6 @@ async def test_constructor_loads_info_from_config(hass):
|
||||
"user_pool_id": "test-user_pool_id",
|
||||
"region": "test-region",
|
||||
"relayer": "test-relayer",
|
||||
"google_actions_sync_url": "http://test-google_actions_sync_url",
|
||||
"subscription_info_url": "http://test-subscription-info-url",
|
||||
"cloudhook_create_url": "http://test-cloudhook_create_url",
|
||||
"remote_api_url": "http://test-remote_api_url",
|
||||
@@ -46,7 +45,6 @@ async def test_constructor_loads_info_from_config(hass):
|
||||
assert cl.user_pool_id == "test-user_pool_id"
|
||||
assert cl.region == "test-region"
|
||||
assert cl.relayer == "test-relayer"
|
||||
assert cl.google_actions_sync_url == "http://test-google_actions_sync_url"
|
||||
assert cl.subscription_info_url == "http://test-subscription-info-url"
|
||||
assert cl.cloudhook_create_url == "http://test-cloudhook_create_url"
|
||||
assert cl.remote_api_url == "http://test-remote_api_url"
|
||||
|
||||
Reference in new issue
Block a user