Fix hue discovery popping up (#14614)

* Fix hue discovery popping up

* Fix result

* Fix tests
This commit is contained in:
Paulus Schoutsen
2018-05-24 14:24:58 -04:00
committed by Paulus Schoutsen
parent 69e86c29a6
commit ef35b8d428
5 changed files with 38 additions and 11 deletions
+20
View File
@@ -284,3 +284,23 @@ async def test_discovery_notification(hass):
await hass.async_block_till_done()
state = hass.states.get('persistent_notification.config_entry_discovery')
assert state is None
async def test_discovery_notification_not_created(hass):
"""Test that we not create a notification when discovery is aborted."""
loader.set_component(hass, 'test', MockModule('test'))
await async_setup_component(hass, 'persistent_notification', {})
class TestFlow(data_entry_flow.FlowHandler):
VERSION = 5
async def async_step_discovery(self, user_input=None):
return self.async_abort(reason='test')
with patch.dict(config_entries.HANDLERS, {'test': TestFlow}):
await hass.config_entries.flow.async_init(
'test', source=data_entry_flow.SOURCE_DISCOVERY)
await hass.async_block_till_done()
state = hass.states.get('persistent_notification.config_entry_discovery')
assert state is None
+2 -1
View File
@@ -21,7 +21,8 @@ def manager():
return handler()
async def async_add_entry(result):
entries.append(result)
if (result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY):
entries.append(result)
manager = data_entry_flow.FlowManager(
None, async_create_flow, async_add_entry)