Snips: (change) Removed unknown intent speech response (#11776)
* Removed unknown intent speech response * Fixed tests, doh! * Woofpull/11806/head
parent
ce9673b06d
commit
0e1cc05189
|
@ -104,7 +104,6 @@ def async_setup(hass, config):
|
|||
except intent.UnknownIntent as err:
|
||||
_LOGGER.warning("Received unknown intent %s",
|
||||
request['intent']['intentName'])
|
||||
snips_response = "Unknown Intent"
|
||||
except intent.IntentError:
|
||||
_LOGGER.exception("Error while handling intent: %s.", intent_type)
|
||||
snips_response = "Error while handling intent"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Test the Snips component."""
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
|
@ -151,42 +152,27 @@ def test_intent_speech_response(hass, mqtt_mock):
|
|||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_snips_unknown_intent(hass, mqtt_mock):
|
||||
"""Test calling unknown Intent via Snips."""
|
||||
event = 'call_service'
|
||||
events = []
|
||||
|
||||
@callback
|
||||
def record_event(event):
|
||||
"""Add recorded event to set."""
|
||||
events.append(event)
|
||||
def test_unknown_intent(hass, mqtt_mock, caplog):
|
||||
"""Test unknown intent."""
|
||||
caplog.set_level(logging.WARNING)
|
||||
result = yield from async_setup_component(hass, "snips", {
|
||||
"snips": {},
|
||||
})
|
||||
assert result
|
||||
payload = """
|
||||
{
|
||||
"input": "what to do",
|
||||
"input": "I don't know what I am supposed to do",
|
||||
"sessionId": "abcdef1234567890",
|
||||
"intent": {
|
||||
"intentName": "unknownIntent"
|
||||
},
|
||||
"slots": []
|
||||
}
|
||||
"""
|
||||
intents = async_mock_intent(hass, 'knownIntent')
|
||||
hass.bus.async_listen(event, record_event)
|
||||
async_fire_mqtt_message(hass, 'hermes/intent/unknownIntent',
|
||||
payload)
|
||||
async_fire_mqtt_message(hass,
|
||||
'hermes/intent/unknownIntent', payload)
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
assert not intents
|
||||
assert len(events) == 1
|
||||
assert events[0].data['domain'] == 'mqtt'
|
||||
assert events[0].data['service'] == 'publish'
|
||||
payload = json.loads(events[0].data['service_data']['payload'])
|
||||
topic = events[0].data['service_data']['topic']
|
||||
assert payload['text'] == 'Unknown Intent'
|
||||
assert topic == 'hermes/dialogueManager/endSession'
|
||||
assert 'Received unknown intent unknownIntent' in caplog.text
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
|
|
Loading…
Reference in New Issue