Address asyncio comments (#3663)

* Template platforms: create_task instead of yield from

* Automation: less yielding, more create_tasking

* Helpers.script: less yielding, more create_tasking

* Deflake logbook test

* Deflake automation reload config test

* MQTT: Use async_add_job and threaded_listener_factory

* Deflake other logbook test

* lint

* Add test for automation trigger service

* MQTT client can be called from within async
This commit is contained in:
Paulus Schoutsen 2016-10-03 22:39:27 -07:00 committed by GitHub
parent f2a12b7ac2
commit d58548dd1c
10 changed files with 123 additions and 76 deletions

View file

@ -50,6 +50,11 @@ class TestComponentLogbook(unittest.TestCase):
logbook.ATTR_ENTITY_ID: 'switch.test_switch'
}, True)
# Logbook entry service call results in firing an event.
# Our service call will unblock when the event listeners have been
# scheduled. This means that they may not have been processed yet.
self.hass.block_till_done()
self.assertEqual(1, len(calls))
last_call = calls[-1]
@ -70,6 +75,11 @@ class TestComponentLogbook(unittest.TestCase):
self.hass.bus.listen(logbook.EVENT_LOGBOOK_ENTRY, event_listener)
self.hass.services.call(logbook.DOMAIN, 'log', {}, True)
# Logbook entry service call results in firing an event.
# Our service call will unblock when the event listeners have been
# scheduled. This means that they may not have been processed yet.
self.hass.block_till_done()
self.assertEqual(0, len(calls))
def test_humanify_filter_sensor(self):