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:
1 parent
f2a12b7ac2
commit
d58548dd1c
10 files changed
+123
-76
No files matched your search
@@ -144,6 +144,35 @@ class TestAutomation(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
self.assertEqual(2, len(self.calls))
|
||||
|
||||
def test_trigger_service_ignoring_condition(self):
|
||||
"""Test triggers."""
|
||||
assert setup_component(self.hass, automation.DOMAIN, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': [
|
||||
{
|
||||
'platform': 'event',
|
||||
'event_type': 'test_event',
|
||||
},
|
||||
],
|
||||
'condition': {
|
||||
'condition': 'state',
|
||||
'entity_id': 'non.existing',
|
||||
'state': 'beer',
|
||||
},
|
||||
'action': {
|
||||
'service': 'test.automation',
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
self.hass.bus.fire('test_event')
|
||||
self.hass.block_till_done()
|
||||
assert len(self.calls) == 0
|
||||
|
||||
self.hass.services.call('automation', 'trigger', blocking=True)
|
||||
self.hass.block_till_done()
|
||||
assert len(self.calls) == 1
|
||||
|
||||
def test_two_conditions_with_and(self):
|
||||
"""Test two and conditions."""
|
||||
entity_id = 'test.entity'
|
||||
@@ -348,6 +377,8 @@ class TestAutomation(unittest.TestCase):
|
||||
|
||||
automation.reload(self.hass)
|
||||
self.hass.block_till_done()
|
||||
# De-flake ?!
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert self.hass.states.get('automation.hello') is None
|
||||
assert self.hass.states.get('automation.bye') is not None
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user