Add example in test how to create list or object in template (#12469)
This commit is contained in:
parent
22a007a785
commit
371fe9c78f
1 changed files with 16 additions and 8 deletions
|
@ -71,13 +71,14 @@ class TestScriptHelper(unittest.TestCase):
|
||||||
script_obj = script.Script(self.hass, cv.SCRIPT_SCHEMA({
|
script_obj = script.Script(self.hass, cv.SCRIPT_SCHEMA({
|
||||||
'event': event,
|
'event': event,
|
||||||
'event_data_template': {
|
'event_data_template': {
|
||||||
'hello': """
|
'dict': {
|
||||||
{% if is_world == 'yes' %}
|
1: '{{ is_world }}',
|
||||||
world
|
2: '{{ is_world }}{{ is_world }}',
|
||||||
{% else %}
|
3: '{{ is_world }}{{ is_world }}{{ is_world }}',
|
||||||
not world
|
},
|
||||||
{% endif %}
|
'list': [
|
||||||
"""
|
'{{ is_world }}', '{{ is_world }}{{ is_world }}'
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -86,7 +87,14 @@ class TestScriptHelper(unittest.TestCase):
|
||||||
self.hass.block_till_done()
|
self.hass.block_till_done()
|
||||||
|
|
||||||
assert len(calls) == 1
|
assert len(calls) == 1
|
||||||
assert calls[0].data.get('hello') == 'world'
|
assert calls[0].data == {
|
||||||
|
'dict': {
|
||||||
|
1: 'yes',
|
||||||
|
2: 'yesyes',
|
||||||
|
3: 'yesyesyes',
|
||||||
|
},
|
||||||
|
'list': ['yes', 'yesyes']
|
||||||
|
}
|
||||||
assert not script_obj.can_cancel
|
assert not script_obj.can_cancel
|
||||||
|
|
||||||
def test_calling_service(self):
|
def test_calling_service(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue