1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Add support for conversation ID (#28620)

This commit is contained in:
Paulus Schoutsen
2019-11-07 12:21:12 -08:00
committed by GitHub
parent 9b5fa2e67c
commit fadb6a3979
5 changed files with 34 additions and 11 deletions

View File

@@ -266,11 +266,14 @@ async def test_http_api_wrong_data(hass, hass_client):
async def test_custom_agent(hass, hass_client):
"""Test a custom conversation agent."""
calls = []
class MyAgent(conversation.AbstractConversationAgent):
"""Test Agent."""
async def async_process(self, text):
async def async_process(self, text, conversation_id):
"""Process some text."""
calls.append((text, conversation_id))
response = intent.IntentResponse()
response.async_set_speech("Test response")
return response
@@ -281,9 +284,16 @@ async def test_custom_agent(hass, hass_client):
client = await hass_client()
resp = await client.post("/api/conversation/process", json={"text": "Test Text"})
resp = await client.post(
"/api/conversation/process",
json={"text": "Test Text", "conversation_id": "test-conv-id"},
)
assert resp.status == 200
assert await resp.json() == {
"card": {},
"speech": {"plain": {"extra_data": None, "speech": "Test response"}},
}
assert len(calls) == 1
assert calls[0][0] == "Test Text"
assert calls[0][1] == "test-conv-id"