Add integration step to onboarding (#23732)
* Return an extra oauth2 auth code during onboarding * Areas in const * Add integration step * Lint * Fix tests * Fix test * Verify integration added to done * Verify step is marked as done
This commit is contained in:
1 parent
07ee3b2eb9
commit
f4016b4aad
9 files changed
+205
-25
No files matched your search
@@ -51,10 +51,28 @@ async def test_is_onboarded():
|
||||
hass.data[onboarding.DOMAIN] = True
|
||||
assert onboarding.async_is_onboarded(hass)
|
||||
|
||||
hass.data[onboarding.DOMAIN] = False
|
||||
hass.data[onboarding.DOMAIN] = {
|
||||
'done': []
|
||||
}
|
||||
assert not onboarding.async_is_onboarded(hass)
|
||||
|
||||
|
||||
async def test_is_user_onboarded():
|
||||
"""Test the is onboarded function."""
|
||||
hass = Mock()
|
||||
hass.data = {}
|
||||
|
||||
assert onboarding.async_is_user_onboarded(hass)
|
||||
|
||||
hass.data[onboarding.DOMAIN] = True
|
||||
assert onboarding.async_is_user_onboarded(hass)
|
||||
|
||||
hass.data[onboarding.DOMAIN] = {
|
||||
'done': []
|
||||
}
|
||||
assert not onboarding.async_is_user_onboarded(hass)
|
||||
|
||||
|
||||
async def test_having_owner_finishes_user_step(hass, hass_storage):
|
||||
"""If owner user already exists, mark user step as complete."""
|
||||
MockUser(is_owner=True).add_to_hass(hass)
|
||||
@@ -70,3 +88,15 @@ async def test_having_owner_finishes_user_step(hass, hass_storage):
|
||||
|
||||
done = hass_storage[onboarding.STORAGE_KEY]['data']['done']
|
||||
assert onboarding.STEP_USER in done
|
||||
|
||||
|
||||
async def test_migration(hass, hass_storage):
|
||||
"""Test migrating onboarding to new version."""
|
||||
hass_storage[onboarding.STORAGE_KEY] = {
|
||||
'version': 1,
|
||||
'data': {
|
||||
'done': ["user"]
|
||||
}
|
||||
}
|
||||
assert await async_setup_component(hass, 'onboarding', {})
|
||||
assert onboarding.async_is_onboarded(hass)
|
||||
Reference in new issue
Block a user