Add flexible error value for value template parsing

This commit is contained in:
Paulus Schoutsen committed 2015-12-12 10:35:15 -08:00
1 parent b1bf6a609e
commit 2b975c8620
2 files changed
+16 -2

No files matched your search

+12
View File
@@ -85,6 +85,18 @@ class TestUtilTemplate(unittest.TestCase):
template.render_with_possible_json_value(
self.hass, '{{ value_json }}', '{ I AM NOT JSON }'))
def test_render_with_possible_json_value_with_template_error(self):
self.assertEqual(
'hello',
template.render_with_possible_json_value(
self.hass, '{{ value_json', 'hello'))
def test_render_with_possible_json_value_with_template_error_error_value(self):
self.assertEqual(
'-',
template.render_with_possible_json_value(
self.hass, '{{ value_json', 'hello', '-'))
def test_raise_exception_on_error(self):
with self.assertRaises(TemplateError):
template.render(self.hass, '{{ invalid_syntax')