Add support for multiple event triggers in automation (#43097)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Franck Nijhof 2020-11-12 11:58:28 +01:00 committed by GitHub
parent 673ac21de4
commit 6f326a7ea4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 131 additions and 64 deletions

View file

@ -59,6 +59,33 @@ async def test_if_fires_on_event(hass, calls):
assert len(calls) == 1
async def test_if_fires_on_multiple_events(hass, calls):
"""Test the firing of events."""
context = Context()
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: {
"trigger": {
"platform": "event",
"event_type": ["test_event", "test2_event"],
},
"action": {"service": "test.automation"},
}
},
)
hass.bus.async_fire("test_event", context=context)
await hass.async_block_till_done()
hass.bus.async_fire("test2_event", context=context)
await hass.async_block_till_done()
assert len(calls) == 2
assert calls[0].context.parent_id == context.id
assert calls[1].context.parent_id == context.id
async def test_if_fires_on_event_extra_data(hass, calls, context_with_user):
"""Test the firing of events still matches with event data and context."""
assert await async_setup_component(