diff --git a/tests/components/notify/test_demo.py b/tests/components/notify/test_demo.py index 079daa48498..3f7ffb576ed 100644 --- a/tests/components/notify/test_demo.py +++ b/tests/components/notify/test_demo.py @@ -1,8 +1,11 @@ """The tests for the notify demo platform.""" +import tempfile import unittest import homeassistant.components.notify as notify from homeassistant.components.notify import demo +from homeassistant.helpers import script +from homeassistant.util import yaml from tests.common import get_test_home_assistant @@ -59,3 +62,34 @@ class TestNotifyDemo(unittest.TestCase): 'title': 'my title', 'data': {'hello': 'world'} } == data + + def test_calling_notify_from_script_loaded_from_yaml(self): + """Test if we can call a notify from a script.""" + yaml_conf = """ +service: notify.notify +data: + data: + push: + sound: US-EN-Morgan-Freeman-Roommate-Is-Arriving.wav +data_template: + message: > + Test 123 {{ 2 + 2 }} +""" + + with tempfile.NamedTemporaryFile() as fp: + fp.write(yaml_conf.encode('utf-8')) + fp.flush() + conf = yaml.load_yaml(fp.name) + + script.call_from_config(self.hass, conf) + self.hass.pool.block_till_done() + self.assertTrue(len(self.events) == 1) + assert { + 'message': 'Test 123 4', + 'target': None, + 'title': 'Home Assistant', + 'data': { + 'push': { + 'sound': + 'US-EN-Morgan-Freeman-Roommate-Is-Arriving.wav'}} + } == self.events[0].data