From 371fe9c78f508e1c2227a4cfc440841d65eaa0b2 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 17 Feb 2018 11:47:20 -0800 Subject: [PATCH] Add example in test how to create list or object in template (#12469) --- tests/helpers/test_script.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/helpers/test_script.py b/tests/helpers/test_script.py index 385b0a5df05..a8ae20ad69b 100644 --- a/tests/helpers/test_script.py +++ b/tests/helpers/test_script.py @@ -71,13 +71,14 @@ class TestScriptHelper(unittest.TestCase): script_obj = script.Script(self.hass, cv.SCRIPT_SCHEMA({ 'event': event, 'event_data_template': { - 'hello': """ - {% if is_world == 'yes' %} - world - {% else %} - not world - {% endif %} - """ + 'dict': { + 1: '{{ is_world }}', + 2: '{{ is_world }}{{ is_world }}', + 3: '{{ is_world }}{{ is_world }}{{ is_world }}', + }, + 'list': [ + '{{ is_world }}', '{{ is_world }}{{ is_world }}' + ] } })) @@ -86,7 +87,14 @@ class TestScriptHelper(unittest.TestCase): self.hass.block_till_done() 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 def test_calling_service(self):