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 Schoutsen 2020-03-09 17:42:26 -07:00 committed by GitHub
parent 87b770be08
commit 8a46d93be4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 19 deletions

View file

@ -236,9 +236,7 @@ class CloudRegisterView(HomeAssistantView):
cloud = hass.data[DOMAIN]
with async_timeout.timeout(REQUEST_TIMEOUT):
await hass.async_add_job(
cloud.auth.register, data["email"], data["password"]
)
await cloud.auth.async_register(data["email"], data["password"])
return self.json_message("ok")
@ -257,7 +255,7 @@ class CloudResendConfirmView(HomeAssistantView):
cloud = hass.data[DOMAIN]
with async_timeout.timeout(REQUEST_TIMEOUT):
await hass.async_add_job(cloud.auth.resend_email_confirm, data["email"])
await cloud.auth.async_resend_email_confirm(data["email"])
return self.json_message("ok")
@ -276,7 +274,7 @@ class CloudForgotPasswordView(HomeAssistantView):
cloud = hass.data[DOMAIN]
with async_timeout.timeout(REQUEST_TIMEOUT):
await hass.async_add_job(cloud.auth.forgot_password, data["email"])
await cloud.auth.async_forgot_password(data["email"])
return self.json_message("ok")
@ -336,7 +334,7 @@ async def websocket_subscription(hass, connection, msg):
# In that case, let's refresh and reconnect
if data.get("provider") and not cloud.is_connected:
_LOGGER.debug("Found disconnected account with valid subscriotion, connecting")
await hass.async_add_executor_job(cloud.auth.renew_access_token)
await cloud.auth.async_renew_access_token()
# Cancel reconnect in progress
if cloud.iot.state != STATE_DISCONNECTED:

View file

@ -2,7 +2,7 @@
"domain": "cloud",
"name": "Home Assistant Cloud",
"documentation": "https://www.home-assistant.io/integrations/cloud",
"requirements": ["hass-nabucasa==0.32"],
"requirements": ["hass-nabucasa==0.32.2"],
"dependencies": ["http", "webhook", "alexa"],
"after_dependencies": ["google_assistant"],
"codeowners": ["@home-assistant/cloud"]

View file

@ -11,7 +11,7 @@ ciso8601==2.1.3
cryptography==2.8
defusedxml==0.6.0
distro==1.4.0
hass-nabucasa==0.32
hass-nabucasa==0.32.2
home-assistant-frontend==20200306.0
importlib-metadata==1.5.0
jinja2>=2.10.3

View file

@ -663,7 +663,7 @@ habitipy==0.2.0
hangups==0.4.9
# homeassistant.components.cloud
hass-nabucasa==0.32
hass-nabucasa==0.32.2
# homeassistant.components.mqtt
hbmqtt==0.9.5

View file

@ -242,7 +242,7 @@ ha-ffmpeg==2.0
hangups==0.4.9
# homeassistant.components.cloud
hass-nabucasa==0.32
hass-nabucasa==0.32.2
# homeassistant.components.mqtt
hbmqtt==0.9.5

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()