2019-02-05 19:31:15 -08:00
|
|
|
"""Tests for the conversation component."""
|
2023-01-19 13:59:02 -05:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from homeassistant.components import conversation
|
|
|
|
from homeassistant.helpers import intent
|
|
|
|
|
|
|
|
|
|
|
|
class MockAgent(conversation.AbstractConversationAgent):
|
|
|
|
"""Test Agent."""
|
|
|
|
|
2023-02-03 23:35:29 -05:00
|
|
|
def __init__(self, agent_id: str) -> None:
|
2023-01-19 13:59:02 -05:00
|
|
|
"""Initialize the agent."""
|
2023-02-03 23:35:29 -05:00
|
|
|
self.agent_id = agent_id
|
2023-01-19 13:59:02 -05:00
|
|
|
self.calls = []
|
|
|
|
self.response = "Test response"
|
|
|
|
|
|
|
|
async def async_process(
|
2023-01-24 22:47:49 -05:00
|
|
|
self, user_input: conversation.ConversationInput
|
2023-01-23 21:38:41 -06:00
|
|
|
) -> conversation.ConversationResult:
|
2023-01-19 13:59:02 -05:00
|
|
|
"""Process some text."""
|
2023-01-24 22:47:49 -05:00
|
|
|
self.calls.append(user_input)
|
|
|
|
response = intent.IntentResponse(language=user_input.language)
|
2023-01-19 13:59:02 -05:00
|
|
|
response.async_set_speech(self.response)
|
|
|
|
return conversation.ConversationResult(
|
2023-01-24 22:47:49 -05:00
|
|
|
response=response, conversation_id=user_input.conversation_id
|
2023-01-19 13:59:02 -05:00
|
|
|
)
|