mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Snips: (change) Removed unknown intent speech response (#11776)
* Removed unknown intent speech response * Fixed tests, doh! * Woof
This commit is contained in:
parent
ce9673b06d
commit
0e1cc05189
@ -104,7 +104,6 @@ def async_setup(hass, config):
|
|||||||
except intent.UnknownIntent as err:
|
except intent.UnknownIntent as err:
|
||||||
_LOGGER.warning("Received unknown intent %s",
|
_LOGGER.warning("Received unknown intent %s",
|
||||||
request['intent']['intentName'])
|
request['intent']['intentName'])
|
||||||
snips_response = "Unknown Intent"
|
|
||||||
except intent.IntentError:
|
except intent.IntentError:
|
||||||
_LOGGER.exception("Error while handling intent: %s.", intent_type)
|
_LOGGER.exception("Error while handling intent: %s.", intent_type)
|
||||||
snips_response = "Error while handling intent"
|
snips_response = "Error while handling intent"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Test the Snips component."""
|
"""Test the Snips component."""
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.bootstrap import async_setup_component
|
from homeassistant.bootstrap import async_setup_component
|
||||||
@ -151,42 +152,27 @@ def test_intent_speech_response(hass, mqtt_mock):
|
|||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def test_snips_unknown_intent(hass, mqtt_mock):
|
def test_unknown_intent(hass, mqtt_mock, caplog):
|
||||||
"""Test calling unknown Intent via Snips."""
|
"""Test unknown intent."""
|
||||||
event = 'call_service'
|
caplog.set_level(logging.WARNING)
|
||||||
events = []
|
|
||||||
|
|
||||||
@callback
|
|
||||||
def record_event(event):
|
|
||||||
"""Add recorded event to set."""
|
|
||||||
events.append(event)
|
|
||||||
result = yield from async_setup_component(hass, "snips", {
|
result = yield from async_setup_component(hass, "snips", {
|
||||||
"snips": {},
|
"snips": {},
|
||||||
})
|
})
|
||||||
assert result
|
assert result
|
||||||
payload = """
|
payload = """
|
||||||
{
|
{
|
||||||
"input": "what to do",
|
"input": "I don't know what I am supposed to do",
|
||||||
|
"sessionId": "abcdef1234567890",
|
||||||
"intent": {
|
"intent": {
|
||||||
"intentName": "unknownIntent"
|
"intentName": "unknownIntent"
|
||||||
},
|
},
|
||||||
"slots": []
|
"slots": []
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
intents = async_mock_intent(hass, 'knownIntent')
|
async_fire_mqtt_message(hass,
|
||||||
hass.bus.async_listen(event, record_event)
|
'hermes/intent/unknownIntent', payload)
|
||||||
async_fire_mqtt_message(hass, 'hermes/intent/unknownIntent',
|
|
||||||
payload)
|
|
||||||
yield from hass.async_block_till_done()
|
yield from hass.async_block_till_done()
|
||||||
|
assert 'Received unknown intent unknownIntent' in caplog.text
|
||||||
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'
|
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
Loading…
x
Reference in New Issue
Block a user