mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Snips ASR and NLU component (#8156)
* Snips ASR and NLU component * Fix warning * Fix warnings * Fix lint issues * Add tests * Fix tabs * Fix newline * Fix quotes * Fix docstrings * Update tests * Remove logs * Fix lint warning * Update API * Fix Snips
This commit is contained in:
committed by
Paulus Schoutsen
parent
c13fdd23c1
commit
b82003ae08
53
tests/components/test_snips.py
Normal file
53
tests/components/test_snips.py
Normal file
@@ -0,0 +1,53 @@
|
||||
"""Test the Snips component."""
|
||||
import asyncio
|
||||
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from tests.common import async_fire_mqtt_message, async_mock_service
|
||||
|
||||
EXAMPLE_MSG = """
|
||||
{
|
||||
"text": "turn the lights green",
|
||||
"intent": {
|
||||
"intent_name": "Lights",
|
||||
"probability": 1
|
||||
},
|
||||
"slots": [
|
||||
{
|
||||
"slot_name": "light_color",
|
||||
"value": {
|
||||
"kind": "Custom",
|
||||
"value": "blue"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_snips_call_action(hass, mqtt_mock):
|
||||
"""Test calling action via Snips."""
|
||||
calls = async_mock_service(hass, 'test', 'service')
|
||||
|
||||
result = yield from async_setup_component(hass, "snips", {
|
||||
"snips": {
|
||||
"intents": {
|
||||
"Lights": {
|
||||
"action": {
|
||||
"service": "test.service",
|
||||
"data_template": {
|
||||
"color": "{{ light_color }}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
assert result
|
||||
|
||||
async_fire_mqtt_message(hass, 'hermes/nlu/intentParsed',
|
||||
EXAMPLE_MSG)
|
||||
yield from hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
call = calls[0]
|
||||
assert call.data.get('color') == 'blue'
|
||||
Reference in New Issue
Block a user