1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Add context to scripts and automations (#16415)

* Add context to script helper

* Update script component

* Add context to automations

* Lint
This commit is contained in:
Paulus Schoutsen
2018-09-04 21:16:24 +02:00
committed by Pascal Vizeli
parent e1501c83f8
commit 746f4ac158
17 changed files with 164 additions and 144 deletions

View File

@@ -1,7 +1,7 @@
"""The tests for the Event automation."""
import unittest
from homeassistant.core import callback
from homeassistant.core import Context, callback
from homeassistant.setup import setup_component
import homeassistant.components.automation as automation
@@ -31,6 +31,8 @@ class TestAutomationEvent(unittest.TestCase):
def test_if_fires_on_event(self):
"""Test the firing of events."""
context = Context()
assert setup_component(self.hass, automation.DOMAIN, {
automation.DOMAIN: {
'trigger': {
@@ -43,9 +45,10 @@ class TestAutomationEvent(unittest.TestCase):
}
})
self.hass.bus.fire('test_event')
self.hass.bus.fire('test_event', context=context)
self.hass.block_till_done()
self.assertEqual(1, len(self.calls))
assert self.calls[0].context is context
automation.turn_off(self.hass)
self.hass.block_till_done()