Add context to login flow (#15914)

* Add context to login flow

* source -> context

* Fix unit test

* Update comment
This commit is contained in:
Jason Hu authored and Paulus Schoutsen committed 2018-08-14 22:06:40 +02:00
1 parent 6d432d19fe
commit 34e1f1b6da
15 files changed
+36 -38

No files matched your search

+3 -2
View File
@@ -1,7 +1,7 @@
"""Tests for the Cast config flow."""
from unittest.mock import patch
from homeassistant import data_entry_flow
from homeassistant import config_entries, data_entry_flow
from homeassistant.setup import async_setup_component
from homeassistant.components import cast
@@ -15,7 +15,8 @@ async def test_creating_entry_sets_up_media_player(hass):
MockDependency('pychromecast', 'discovery'), \
patch('pychromecast.discovery.discover_chromecasts',
return_value=True):
result = await hass.config_entries.flow.async_init(cast.DOMAIN)
result = await hass.config_entries.flow.async_init(
cast.DOMAIN, context={'source': config_entries.SOURCE_USER})
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
await hass.async_block_till_done()
@@ -202,7 +202,6 @@ def test_create_account(hass, client):
'handler': 'test',
'title': 'Test Entry',
'type': 'create_entry',
'source': 'user',
'version': 1,
}
@@ -264,7 +263,6 @@ def test_two_step_flow(hass, client):
'type': 'create_entry',
'title': 'user-title',
'version': 1,
'source': 'user',
}
@@ -295,7 +293,7 @@ def test_get_progress_index(hass, client):
{
'flow_id': form['flow_id'],
'handler': 'test',
'source': 'hassio'
'context': {'source': 'hassio'}
}
]
+3 -2
View File
@@ -1,7 +1,7 @@
"""Tests for the Sonos config flow."""
from unittest.mock import patch
from homeassistant import data_entry_flow
from homeassistant import config_entries, data_entry_flow
from homeassistant.setup import async_setup_component
from homeassistant.components import sonos
@@ -13,7 +13,8 @@ async def test_creating_entry_sets_up_media_player(hass):
with patch('homeassistant.components.media_player.sonos.async_setup_entry',
return_value=mock_coro(True)) as mock_setup, \
patch('soco.discover', return_value=True):
result = await hass.config_entries.flow.async_init(sonos.DOMAIN)
result = await hass.config_entries.flow.async_init(
sonos.DOMAIN, context={'source': config_entries.SOURCE_USER})
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
await hass.async_block_till_done()