Verify cloud user exists during boot (#25119)

This commit is contained in:
Paulus Schoutsen authored and Pascal Vizeli committed 2019-07-13 09:33:31 +02:00
1 parent 59f6fd7630
commit 8ec75cf883
2 files changed
+37 -1

No files matched your search

+30
View File
@@ -127,6 +127,36 @@ async def test_setup_existing_cloud_user(hass, hass_storage):
assert hass_storage[STORAGE_KEY]['data']['cloud_user'] == user.id
async def test_setup_invalid_cloud_user(hass, hass_storage):
"""Test setup with API push default data."""
hass_storage[STORAGE_KEY] = {
'version': 1,
'data': {
'cloud_user': 'non-existing'
}
}
with patch('hass_nabucasa.Cloud.start', return_value=mock_coro()):
result = await async_setup_component(hass, 'cloud', {
'http': {},
'cloud': {
cloud.CONF_MODE: cloud.MODE_DEV,
'cognito_client_id': 'test-cognito_client_id',
'user_pool_id': 'test-user_pool_id',
'region': 'test-region',
'relayer': 'test-relayer',
}
})
assert result
assert hass_storage[STORAGE_KEY]['data']['cloud_user'] != 'non-existing'
cloud_user = await hass.auth.async_get_user(
hass_storage[STORAGE_KEY]['data']['cloud_user']
)
assert cloud_user
assert cloud_user.groups[0].id == GROUP_ID_ADMIN
async def test_setup_setup_cloud_user(hass, hass_storage):
"""Test setup with API push default data."""
hass_storage[STORAGE_KEY] = {