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:
committed by
Pascal Vizeli
parent
e1501c83f8
commit
746f4ac158
@@ -1,7 +1,7 @@
|
||||
"""The tests for the location automation."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import Context, callback
|
||||
from homeassistant.setup import setup_component
|
||||
from homeassistant.components import automation, zone
|
||||
|
||||
@@ -40,6 +40,7 @@ class TestAutomationZone(unittest.TestCase):
|
||||
|
||||
def test_if_fires_on_zone_enter(self):
|
||||
"""Test for firing on zone enter."""
|
||||
context = Context()
|
||||
self.hass.states.set('test.entity', 'hello', {
|
||||
'latitude': 32.881011,
|
||||
'longitude': -117.234758
|
||||
@@ -70,10 +71,11 @@ class TestAutomationZone(unittest.TestCase):
|
||||
self.hass.states.set('test.entity', 'hello', {
|
||||
'latitude': 32.880586,
|
||||
'longitude': -117.237564
|
||||
})
|
||||
}, context=context)
|
||||
self.hass.block_till_done()
|
||||
|
||||
self.assertEqual(1, len(self.calls))
|
||||
assert self.calls[0].context is context
|
||||
self.assertEqual(
|
||||
'zone - test.entity - hello - hello - test',
|
||||
self.calls[0].data['some'])
|
||||
|
||||
Reference in New Issue
Block a user