Beispiel #1
0
def test_init():
    msg1 = Message(text="message 1")
    msg2 = Message(text="message 2")
    headers = {"key1": "value1", "key2": 1}
    performance = PerformanceInfo()
    response = Response(messages=[msg1, msg2],
                        headers=headers,
                        performance=performance)
    assert response.messages == [msg1, msg2]
    assert response.headers == headers
    assert isinstance(response.performance, PerformanceInfo)
Beispiel #2
0
def test_from_dict():
    # setup response dict
    msg1 = Message(text="message 1")
    msg2 = Message(text="message 2")
    headers = {"key1": "value1", "key2": 1}
    performance = PerformanceInfo()
    response_dict = Response(messages=[msg1, msg2],
                             headers=headers,
                             performance=performance).to_dict()
    # restore
    response = Response.from_dict(response_dict)
    assert response.messages[0].text == msg1.text
    assert response.messages[1].text == msg2.text
    assert response.headers == headers
    assert isinstance(response.performance, PerformanceInfo)
Beispiel #3
0
def test_execute_default():
    ds = MyDialog()
    performance = PerformanceInfo()
    context = Context("TEST", "test_user")
    context.topic.is_new = True
    request = Message(channel="TEST", channel_user_id="test_user", text="hello")
    response = ds.execute(request, context, None, performance)
    assert response.messages == []
    assert request.entities == {}
    assert context.data == {}
Beispiel #4
0
def test_to_channel_message():
    # text messages
    message = ClovaAdapter._to_channel_message(
        Message(text="hello", entities={"end_session": True, "reprompt": None}))
    assert message["speech_value"] == "hello"
    assert message["end_session"] is True
    assert message["reprompt"] is None

    # url messages
    message = ClovaAdapter._to_channel_message(
        Message(text="http://uezo.net", type="url",
                entities={"end_session": True, "reprompt": None}))
    assert message["speech_value"].value == URL("http://uezo.net").value
    assert message["end_session"] is True
    assert message["reprompt"] is None

    # end_session and reprompt
    message = ClovaAdapter._to_channel_message(
        Message(text="hello", entities={"end_session": False, "reprompt": "are you okay?"}))
    assert message["speech_value"] == "hello"
    assert message["end_session"] is False
    assert message["reprompt"] == "are you okay?"
Beispiel #5
0
def test_to_channel_message():
    message = SymphonyAdapter._to_channel_message(Message(text="hello"))
    assert message == {"message": "<messageML>hello</messageML>"}
Beispiel #6
0
 def _to_minette_message(event):
     return Message(text=event.text)