Upgrade hass_nabucasa to 0.32.2 (#32522)

* Upgrade hass_nabucasa to 32.1

* Fix tests

* Update hass-nabucasa to 0.32.2

Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
This commit is contained in:
Paulus SchoutsenandPascal Vizeli authored and GitHub committed 2020-03-09 17:42:26 -07:00
1 parent 87b770be08
commit 8a46d93be4
6 files changed
+20 -19

No files matched your search

+12 -9
View File
@@ -1,8 +1,9 @@
"""Tests for the HTTP API for the cloud component."""
import asyncio
from ipaddress import ip_network
from unittest.mock import MagicMock, Mock, patch
from unittest.mock import MagicMock, Mock
from asynctest import patch
from hass_nabucasa import thingtalk
from hass_nabucasa.auth import Unauthenticated, UnknownError
from hass_nabucasa.const import STATE_CONNECTED
@@ -131,7 +132,7 @@ async def test_login_view_random_exception(cloud_client):
async def test_login_view_invalid_json(cloud_client):
"""Try logging in with invalid JSON."""
with patch("hass_nabucasa.auth.CognitoAuth.login") as mock_login:
with patch("hass_nabucasa.auth.CognitoAuth.async_login") as mock_login:
req = await cloud_client.post("/api/cloud/login", data="Not JSON")
assert req.status == 400
assert len(mock_login.mock_calls) == 0
@@ -139,7 +140,7 @@ async def test_login_view_invalid_json(cloud_client):
async def test_login_view_invalid_schema(cloud_client):
"""Try logging in with invalid schema."""
with patch("hass_nabucasa.auth.CognitoAuth.login") as mock_login:
with patch("hass_nabucasa.auth.CognitoAuth.async_login") as mock_login:
req = await cloud_client.post("/api/cloud/login", json={"invalid": "schema"})
assert req.status == 400
assert len(mock_login.mock_calls) == 0
@@ -148,7 +149,7 @@ async def test_login_view_invalid_schema(cloud_client):
async def test_login_view_request_timeout(cloud_client):
"""Test request timeout while trying to log in."""
with patch(
"hass_nabucasa.auth.CognitoAuth.login", side_effect=asyncio.TimeoutError
"hass_nabucasa.auth.CognitoAuth.async_login", side_effect=asyncio.TimeoutError
):
req = await cloud_client.post(
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
@@ -159,7 +160,9 @@ async def test_login_view_request_timeout(cloud_client):
async def test_login_view_invalid_credentials(cloud_client):
"""Test logging in with invalid credentials."""
with patch("hass_nabucasa.auth.CognitoAuth.login", side_effect=Unauthenticated):
with patch(
"hass_nabucasa.auth.CognitoAuth.async_login", side_effect=Unauthenticated
):
req = await cloud_client.post(
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
)
@@ -169,7 +172,7 @@ async def test_login_view_invalid_credentials(cloud_client):
async def test_login_view_unknown_error(cloud_client):
"""Test unknown error while logging in."""
with patch("hass_nabucasa.auth.CognitoAuth.login", side_effect=UnknownError):
with patch("hass_nabucasa.auth.CognitoAuth.async_login", side_effect=UnknownError):
req = await cloud_client.post(
"/api/cloud/login", json={"email": "my_username", "password": "my_password"}
)
@@ -382,7 +385,7 @@ async def test_websocket_subscription_reconnect(
client = await hass_ws_client(hass)
with patch(
"hass_nabucasa.auth.CognitoAuth.renew_access_token"
"hass_nabucasa.auth.CognitoAuth.async_renew_access_token"
) as mock_renew, patch("hass_nabucasa.iot.CloudIoT.connect") as mock_connect:
await client.send_json({"id": 5, "type": "cloud/subscription"})
response = await client.receive_json()
@@ -401,7 +404,7 @@ async def test_websocket_subscription_no_reconnect_if_connected(
client = await hass_ws_client(hass)
with patch(
"hass_nabucasa.auth.CognitoAuth.renew_access_token"
"hass_nabucasa.auth.CognitoAuth.async_renew_access_token"
) as mock_renew, patch("hass_nabucasa.iot.CloudIoT.connect") as mock_connect:
await client.send_json({"id": 5, "type": "cloud/subscription"})
response = await client.receive_json()
@@ -419,7 +422,7 @@ async def test_websocket_subscription_no_reconnect_if_expired(
client = await hass_ws_client(hass)
with patch(
"hass_nabucasa.auth.CognitoAuth.renew_access_token"
"hass_nabucasa.auth.CognitoAuth.async_renew_access_token"
) as mock_renew, patch("hass_nabucasa.iot.CloudIoT.connect") as mock_connect:
await client.send_json({"id": 5, "type": "cloud/subscription"})
response = await client.receive_json()