Renaming API.AI to Dialogflow (#10006)

* Rename API.AI to Dialogflow

* Rename API.AI to Dialogflow
This commit is contained in:
Fabian Affolter authored and Paulus Schoutsen committed 2017-10-21 13:12:23 -07:00
1 parent bf26b75d27
commit 28b7a3da32
2 files changed
+53 -49

No files matched your search

@@ -1,4 +1,4 @@
"""The tests for the APIAI component."""
"""The tests for the Dialogflow component."""
# pylint: disable=protected-access
import json
import unittest
@@ -7,14 +7,14 @@ import requests
from homeassistant.core import callback
from homeassistant import setup, const
from homeassistant.components import apiai, http
from homeassistant.components import dialogflow, http
from tests.common import get_test_instance_port, get_test_home_assistant
API_PASSWORD = "test1234"
API_PASSWORD = 'test1234'
SERVER_PORT = get_test_instance_port()
BASE_API_URL = "http://127.0.0.1:{}".format(SERVER_PORT)
INTENTS_API_URL = "{}{}".format(BASE_API_URL, apiai.INTENTS_API_ENDPOINT)
INTENTS_API_URL = "{}{}".format(BASE_API_URL, dialogflow.INTENTS_API_ENDPOINT)
HA_HEADERS = {
const.HTTP_HEADER_HA_AUTH: API_PASSWORD,
@@ -27,9 +27,9 @@ INTENT_NAME = "tests"
REQUEST_ID = "19ef7e78-fe15-4e94-99dd-0c0b1e8753c3"
REQUEST_TIMESTAMP = "2017-01-21T17:54:18.952Z"
CONTEXT_NAME = "78a5db95-b7d6-4d50-9c9b-2fc73a5e34c3_id_dialog_context"
MAX_RESPONSE_TIME = 5 # https://docs.api.ai/docs/webhook
MAX_RESPONSE_TIME = 5 # https://dialogflow.com/docs/fulfillment
# An unknown action takes 8s to return. Request timeout should be bigger to
# An unknown action takes 8 s to return. Request timeout should be bigger to
# allow the test to finish
REQUEST_TIMEOUT = 15
@@ -46,19 +46,23 @@ def setUpModule():
hass = get_test_home_assistant()
setup.setup_component(
hass, http.DOMAIN,
{http.DOMAIN: {http.CONF_API_PASSWORD: API_PASSWORD,
http.CONF_SERVER_PORT: SERVER_PORT}})
hass, http.DOMAIN, {
http.DOMAIN: {
http.CONF_API_PASSWORD: API_PASSWORD,
http.CONF_SERVER_PORT: SERVER_PORT,
}
}
)
@callback
def mock_service(call):
"""Mock action call."""
calls.append(call)
hass.services.register("test", "apiai", mock_service)
hass.services.register('test', 'dialogflow', mock_service)
assert setup.setup_component(hass, apiai.DOMAIN, {
"apiai": {},
assert setup.setup_component(hass, dialogflow.DOMAIN, {
"dialogflow": {},
})
assert setup.setup_component(hass, "intent_script", {
"intent_script": {
@@ -92,7 +96,7 @@ def setUpModule():
"text": "Service called",
},
"action": {
"service": "test.apiai",
"service": "test.dialogflow",
"data_template": {
"hello": "{{ ZodiacSign }}"
},
@@ -112,12 +116,13 @@ def tearDownModule():
def _intent_req(data):
return requests.post(INTENTS_API_URL, data=json.dumps(data),
timeout=REQUEST_TIMEOUT, headers=HA_HEADERS)
return requests.post(
INTENTS_API_URL, data=json.dumps(data), timeout=REQUEST_TIMEOUT,
headers=HA_HEADERS)
class TestApiai(unittest.TestCase):
"""Test APIAI."""
class TestDialogflow(unittest.TestCase):
"""Test Dialogflow."""
def tearDown(self):
"""Stop everything that was started."""
@@ -167,7 +172,7 @@ class TestApiai(unittest.TestCase):
self.assertEqual("", req.text)
def test_intent_slot_filling(self):
"""Test when API.AI asks for slot-filling return none."""
"""Test when Dialogflow asks for slot-filling return none."""
data = {
"id": REQUEST_ID,
"timestamp": REQUEST_TIMESTAMP,
@@ -424,7 +429,7 @@ class TestApiai(unittest.TestCase):
self.assertEqual(call_count + 1, len(calls))
call = calls[-1]
self.assertEqual("test", call.domain)
self.assertEqual("apiai", call.service)
self.assertEqual("dialogflow", call.service)
self.assertEqual(["switch.test"], call.data.get("entity_id"))
self.assertEqual("virgo", call.data.get("hello"))
@@ -471,7 +476,7 @@ class TestApiai(unittest.TestCase):
self.assertEqual(200, req.status_code)
text = req.json().get("speech")
self.assertEqual(
"You have not defined an action in your api.ai intent.", text)
"You have not defined an action in your Dialogflow intent.", text)
def test_intent_with_unknown_action(self):
"""Test a intent with an action not defined in the conf."""