* Add intent component * Add intent script component * Add shopping list component * Convert Snips to use intent component * Convert Alexa to use intent component * Lint * Fix Alexa tests * Update snips test * Add intent support to conversation * Add API to view shopping list contents * Lint * Fix demo test * Lint * lint * Remove type from slot schema * Add dependency to conversation * Move intent to be a helper * Fix conversation * Clean up intent helper * Fix Alexa * Snips to use new hass.components * Allow registering intents with conversation at any point in time * Shopping list to register sentences * Add HTTP endpoint to Conversation * Add async action option to intent_script * Update API.ai to use intents * Cleanup Alexa * Shopping list component to register built-in panel * Rename shopping list intent to inlude Hass name
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
"""Test intent_script component."""
|
|
import asyncio
|
|
|
|
from homeassistant.bootstrap import async_setup_component
|
|
from homeassistant.helpers import intent
|
|
|
|
from tests.common import async_mock_service
|
|
|
|
|
|
@asyncio.coroutine
|
|
def test_intent_script(hass):
|
|
"""Test intent scripts work."""
|
|
calls = async_mock_service(hass, 'test', 'service')
|
|
|
|
yield from async_setup_component(hass, 'intent_script', {
|
|
'intent_script': {
|
|
'HelloWorld': {
|
|
'action': {
|
|
'service': 'test.service',
|
|
'data_template': {
|
|
'hello': '{{ name }}'
|
|
}
|
|
},
|
|
'card': {
|
|
'title': 'Hello {{ name }}',
|
|
'content': 'Content for {{ name }}',
|
|
},
|
|
'speech': {
|
|
'text': 'Good morning {{ name }}'
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
response = yield from intent.async_handle(
|
|
hass, 'test', 'HelloWorld', {'name': {'value': 'Paulus'}}
|
|
)
|
|
|
|
assert len(calls) == 1
|
|
assert calls[0].data['hello'] == 'Paulus'
|
|
|
|
assert response.speech['plain']['speech'] == 'Good morning Paulus'
|
|
|
|
assert response.card['simple']['title'] == 'Hello Paulus'
|
|
assert response.card['simple']['content'] == 'Content for Paulus'
|