Add notify test being called from a YAML/script combi
This commit is contained in:
parent
e773526714
commit
253628da11
1 changed files with 34 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue