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 2018-08-13 02:27:18 -07:00 committed by Paulus Schoutsen
parent 45f12dd3c7
commit 50daef9a52
15 changed files with 36 additions and 38 deletions

View file

@ -116,7 +116,8 @@ def test_add_entry_calls_setup_entry(hass, manager):
})
with patch.dict(config_entries.HANDLERS, {'comp': TestFlow, 'beer': 5}):
yield from manager.flow.async_init('comp')
yield from manager.flow.async_init(
'comp', context={'source': config_entries.SOURCE_USER})
yield from hass.async_block_till_done()
assert len(mock_setup_entry.mock_calls) == 1
@ -171,7 +172,8 @@ async def test_saving_and_loading(hass):
)
with patch.dict(config_entries.HANDLERS, {'test': TestFlow}):
await hass.config_entries.flow.async_init('test')
await hass.config_entries.flow.async_init(
'test', context={'source': config_entries.SOURCE_USER})
class Test2Flow(data_entry_flow.FlowHandler):
VERSION = 3
@ -187,7 +189,8 @@ async def test_saving_and_loading(hass):
with patch('homeassistant.config_entries.HANDLERS.get',
return_value=Test2Flow):
await hass.config_entries.flow.async_init('test')
await hass.config_entries.flow.async_init(
'test', context={'source': config_entries.SOURCE_USER})
# To trigger the call_later
async_fire_time_changed(hass, dt.utcnow() + timedelta(seconds=1))