diff --git a/homeassistant/components/cloud/http_api.py b/homeassistant/components/cloud/http_api.py index 9afaad422ba..c532a2063a7 100644 --- a/homeassistant/components/cloud/http_api.py +++ b/homeassistant/components/cloud/http_api.py @@ -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: diff --git a/homeassistant/components/cloud/manifest.json b/homeassistant/components/cloud/manifest.json index b91af34a96a..cfbb221c164 100644 --- a/homeassistant/components/cloud/manifest.json +++ b/homeassistant/components/cloud/manifest.json @@ -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"] diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index c782bbbd4ea..523926ca22e 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -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 diff --git a/requirements_all.txt b/requirements_all.txt index 8c8c005bd96..acfebe8c4d0 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 39f9492ab7a..54ecf61d031 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -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 diff --git a/tests/components/cloud/test_http_api.py b/tests/components/cloud/test_http_api.py index dbc936b9216..8bfa6185e9b 100644 --- a/tests/components/cloud/test_http_api.py +++ b/tests/components/cloud/test_http_api.py @@ -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()