Snips add say and say_actions services (new) (#11596)
* Added snips.say and snips.say_action services * Added snips.say and snips.say_action services * Merged services.yaml changes I missed * added tests for new service configs * Woof * Woof Woof * Changed attribute names to follow hass standards. * updated test_snips with new attribute names
This commit is contained in:
1 parent
cc236529c4
commit
b8e4c2ff69
3 files changed
+158
-1
No files matched your search
@@ -4,7 +4,10 @@ import json
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from tests.common import async_fire_mqtt_message, async_mock_intent
|
||||
from tests.common import (async_fire_mqtt_message, async_mock_intent,
|
||||
async_mock_service)
|
||||
from homeassistant.components.snips import (SERVICE_SCHEMA_SAY,
|
||||
SERVICE_SCHEMA_SAY_ACTION)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
@@ -238,3 +241,66 @@ def test_snips_intent_username(hass, mqtt_mock):
|
||||
intent = intents[0]
|
||||
assert intent.platform == 'snips'
|
||||
assert intent.intent_type == 'Lights'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_snips_say(hass, caplog):
|
||||
"""Test snips say with invalid config."""
|
||||
calls = async_mock_service(hass, 'snips', 'say',
|
||||
SERVICE_SCHEMA_SAY)
|
||||
|
||||
data = {'text': 'Hello'}
|
||||
yield from hass.services.async_call('snips', 'say', data)
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 1
|
||||
assert calls[0].domain == 'snips'
|
||||
assert calls[0].service == 'say'
|
||||
assert calls[0].data['text'] == 'Hello'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_snips_say_action(hass, caplog):
|
||||
"""Test snips say_action with invalid config."""
|
||||
calls = async_mock_service(hass, 'snips', 'say_action',
|
||||
SERVICE_SCHEMA_SAY_ACTION)
|
||||
|
||||
data = {'text': 'Hello', 'intent_filter': ['myIntent']}
|
||||
yield from hass.services.async_call('snips', 'say_action', data)
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 1
|
||||
assert calls[0].domain == 'snips'
|
||||
assert calls[0].service == 'say_action'
|
||||
assert calls[0].data['text'] == 'Hello'
|
||||
assert calls[0].data['intent_filter'] == ['myIntent']
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_snips_say_invalid_config(hass, caplog):
|
||||
"""Test snips say with invalid config."""
|
||||
calls = async_mock_service(hass, 'snips', 'say',
|
||||
SERVICE_SCHEMA_SAY)
|
||||
|
||||
data = {'text': 'Hello', 'badKey': 'boo'}
|
||||
yield from hass.services.async_call('snips', 'say', data)
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 0
|
||||
assert 'ERROR' in caplog.text
|
||||
assert 'Invalid service data' in caplog.text
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_snips_say_action_invalid_config(hass, caplog):
|
||||
"""Test snips say_action with invalid config."""
|
||||
calls = async_mock_service(hass, 'snips', 'say_action',
|
||||
SERVICE_SCHEMA_SAY_ACTION)
|
||||
|
||||
data = {'text': 'Hello', 'can_be_enqueued': 'notabool'}
|
||||
yield from hass.services.async_call('snips', 'say_action', data)
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
assert len(calls) == 0
|
||||
assert 'ERROR' in caplog.text
|
||||
assert 'Invalid service data' in caplog.text
|
||||
Reference in new issue
Block a user