mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Warn if config invalid shape for script
This commit is contained in:
parent
d4f0f0ffd3
commit
2861bbb02c
@ -76,8 +76,9 @@ def setup(hass, config):
|
|||||||
_LOGGER.warn("Found invalid key for script: %s. Use %s instead.",
|
_LOGGER.warn("Found invalid key for script: %s. Use %s instead.",
|
||||||
object_id, slugify(object_id))
|
object_id, slugify(object_id))
|
||||||
continue
|
continue
|
||||||
if not cfg.get(CONF_SEQUENCE):
|
if not isinstance(cfg.get(CONF_SEQUENCE), list):
|
||||||
_LOGGER.warn("Missing key 'sequence' for script %s", object_id)
|
_LOGGER.warn("Key 'sequence' for script %s should be a list",
|
||||||
|
object_id)
|
||||||
continue
|
continue
|
||||||
alias = cfg.get(CONF_ALIAS, object_id)
|
alias = cfg.get(CONF_ALIAS, object_id)
|
||||||
script = Script(hass, object_id, alias, cfg[CONF_SEQUENCE])
|
script = Script(hass, object_id, alias, cfg[CONF_SEQUENCE])
|
||||||
|
@ -27,23 +27,10 @@ class TestScript(unittest.TestCase):
|
|||||||
""" Stop down stuff we started. """
|
""" Stop down stuff we started. """
|
||||||
self.hass.stop()
|
self.hass.stop()
|
||||||
|
|
||||||
def test_setup_with_empty_sequence(self):
|
|
||||||
self.assertTrue(script.setup(self.hass, {
|
|
||||||
'script': {
|
|
||||||
'test': {
|
|
||||||
'sequence': []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
|
|
||||||
self.assertIsNone(self.hass.states.get(ENTITY_ID))
|
|
||||||
|
|
||||||
def test_setup_with_missing_sequence(self):
|
def test_setup_with_missing_sequence(self):
|
||||||
self.assertTrue(script.setup(self.hass, {
|
self.assertTrue(script.setup(self.hass, {
|
||||||
'script': {
|
'script': {
|
||||||
'test': {
|
'test': {}
|
||||||
'sequence': []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@ -60,6 +47,19 @@ class TestScript(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(0, len(self.hass.states.entity_ids('script')))
|
self.assertEqual(0, len(self.hass.states.entity_ids('script')))
|
||||||
|
|
||||||
|
def test_setup_with_dict_as_sequence(self):
|
||||||
|
self.assertTrue(script.setup(self.hass, {
|
||||||
|
'script': {
|
||||||
|
'test': {
|
||||||
|
'sequence': {
|
||||||
|
'event': 'test_event'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
self.assertEqual(0, len(self.hass.states.entity_ids('script')))
|
||||||
|
|
||||||
def test_firing_event(self):
|
def test_firing_event(self):
|
||||||
event = 'test_event'
|
event = 'test_event'
|
||||||
calls = []
|
calls = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user