Improve cloud error handling (#20729)

* Improve cloud error handling

* Lint
This commit is contained in:
Paulus Schoutsen authored and Pascal Vizeli committed 2019-02-04 10:14:30 +01:00
1 parent a3c8439ce2
commit 07b5b68a51
2 files changed
+18 -3

No files matched your search

+12
View File
@@ -111,6 +111,18 @@ def test_login_view(hass, cloud_client, mock_cognito):
assert result_pass == 'my_password'
async def test_login_view_random_exception(cloud_client):
"""Try logging in with invalid JSON."""
with patch('async_timeout.timeout', side_effect=ValueError('Boom')):
req = await cloud_client.post('/api/cloud/login', json={
'email': 'my_username',
'password': 'my_password'
})
assert req.status == 502
resp = await req.json()
assert resp == {'code': 'valueerror', 'message': 'Unexpected error: Boom'}
@asyncio.coroutine
def test_login_view_invalid_json(cloud_client):
"""Try logging in with invalid JSON."""