mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +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.",
|
||||
object_id, slugify(object_id))
|
||||
continue
|
||||
if not cfg.get(CONF_SEQUENCE):
|
||||
_LOGGER.warn("Missing key 'sequence' for script %s", object_id)
|
||||
if not isinstance(cfg.get(CONF_SEQUENCE), list):
|
||||
_LOGGER.warn("Key 'sequence' for script %s should be a list",
|
||||
object_id)
|
||||
continue
|
||||
alias = cfg.get(CONF_ALIAS, object_id)
|
||||
script = Script(hass, object_id, alias, cfg[CONF_SEQUENCE])
|
||||
|
@ -27,23 +27,10 @@ class TestScript(unittest.TestCase):
|
||||
""" Stop down stuff we started. """
|
||||
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):
|
||||
self.assertTrue(script.setup(self.hass, {
|
||||
'script': {
|
||||
'test': {
|
||||
'sequence': []
|
||||
}
|
||||
'test': {}
|
||||
}
|
||||
}))
|
||||
|
||||
@ -60,6 +47,19 @@ class TestScript(unittest.TestCase):
|
||||
|
||||
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):
|
||||
event = 'test_event'
|
||||
calls = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user