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:
parent
f2a12b7ac2
commit
d58548dd1c
10 changed files with 123 additions and 76 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue