Add script logic into helper.

This commit is contained in:
Paulus Schoutsen 2016-04-21 15:52:20 -07:00
parent 4e568f8b99
commit f76d545a08
9 changed files with 219 additions and 238 deletions

View file

@ -34,13 +34,6 @@ class TestScript(unittest.TestCase):
'sequence': [{'event': 'bla'}]
}
},
{
'test': {
'sequence': {
'event': 'test_event'
}
}
},
{
'test': {
'sequence': {
@ -49,7 +42,6 @@ class TestScript(unittest.TestCase):
}
}
},
):
assert not _setup_component(self.hass, 'script', {
'script': value
@ -206,45 +198,6 @@ class TestScript(unittest.TestCase):
self.assertEqual(2, len(calls))
def test_alt_delay(self):
"""Test alternative delay config format."""
event = 'test_event'
calls = []
def record_event(event):
"""Add recorded event to set."""
calls.append(event)
self.hass.bus.listen(event, record_event)
assert _setup_component(self.hass, 'script', {
'script': {
'test': {
'sequence': [{
'event': event,
}, {
'delay': None,
'seconds': 5
}, {
'event': event,
}]
}
}
})
script.turn_on(self.hass, ENTITY_ID)
self.hass.pool.block_till_done()
self.assertTrue(script.is_on(self.hass, ENTITY_ID))
self.assertEqual(1, len(calls))
future = dt_util.utcnow() + timedelta(seconds=5)
fire_time_changed(self.hass, future)
self.hass.pool.block_till_done()
self.assertFalse(script.is_on(self.hass, ENTITY_ID))
self.assertEqual(2, len(calls))
def test_cancel_while_delay(self):
"""Test the cancelling while the delay is present."""
event = 'test_event'