Exemplo n.º 1
0
async def test_dispatcher_utter_custom_message(default_dispatcher_collecting):
    elements = [
        Element(title="hey there",
                subtitle="welcome",
                buttons=[
                    Button(title="Btn1", payload="/btn1"),
                    Button(title="Btn2", payload="/btn2")
                ]),
        Element(title="another title",
                subtitle="another subtitle",
                buttons=[
                    Button(title="Btn3", payload="/btn3"),
                    Button(title="Btn4", payload="/btn4")
                ])
    ]
    await default_dispatcher_collecting.utter_custom_message(*elements)
    collected = default_dispatcher_collecting.output_channel.messages
    assert len(collected) == 2
    assert collected[0]['text'] == "hey there : welcome"
    assert collected[0]['buttons'] == [{
        'payload': u'/btn1',
        'title': u'Btn1'
    }, {
        'payload': u'/btn2',
        'title': u'Btn2'
    }]
    assert collected[1]['text'] == "another title : another subtitle"
    assert collected[1]['buttons'] == [{
        'payload': u'/btn3',
        'title': u'Btn3'
    }, {
        'payload': u'/btn4',
        'title': u'Btn4'
    }]
Exemplo n.º 2
0
async def test_dispatcher_utter_custom_message(default_dispatcher_collecting):
    elements = [
        Element(
            title="hey there",
            subtitle="welcome",
            buttons=[
                Button(title="Btn1", payload="/btn1"),
                Button(title="Btn2", payload="/btn2"),
            ],
        ),
        Element(
            title="another title",
            subtitle="another subtitle",
            buttons=[
                Button(title="Btn3", payload="/btn3"),
                Button(title="Btn4", payload="/btn4"),
            ],
        ),
    ]
    await default_dispatcher_collecting.utter_custom_message(*elements)
    collected = default_dispatcher_collecting.output_channel.messages
    assert len(collected) == 2
    assert collected[0]["text"] == "hey there : welcome"
    assert collected[0]["buttons"] == [
        {"payload": "/btn1", "title": "Btn1"},
        {"payload": "/btn2", "title": "Btn2"},
    ]
    assert collected[1]["text"] == "another title : another subtitle"
    assert collected[1]["buttons"] == [
        {"payload": "/btn3", "title": "Btn3"},
        {"payload": "/btn4", "title": "Btn4"},
    ]
Exemplo n.º 3
0
async def test_dispatcher_utter_buttons(default_dispatcher_collecting):
    buttons = [
        Button(title="Btn1", payload="/btn1"),
        Button(title="Btn2", payload="/btn2"),
    ]
    await default_dispatcher_collecting.utter_button_message("my message", buttons)
    collected = default_dispatcher_collecting.output_channel.messages
    assert len(collected) == 1
    assert collected[0]["text"] == "my message"
    assert collected[0]["buttons"] == [
        {"payload": "/btn1", "title": "Btn1"},
        {"payload": "/btn2", "title": "Btn2"},
    ]
Exemplo n.º 4
0
async def test_dispatcher_utter_buttons(default_dispatcher_collecting):
    buttons = [
        Button(title="Btn1", payload="/btn1"),
        Button(title="Btn2", payload="/btn2")
    ]
    await default_dispatcher_collecting.utter_button_message(
        "my message", buttons)
    collected = default_dispatcher_collecting.output_channel.messages
    assert len(collected) == 1
    assert collected[0]['text'] == "my message"
    assert collected[0]['buttons'] == [{
        'payload': u'/btn1',
        'title': u'Btn1'
    }, {
        'payload': u'/btn2',
        'title': u'Btn2'
    }]
Exemplo n.º 5
0
async def test_logging_of_bot_utterances_on_tracker(
    default_processor, default_dispatcher_collecting, default_agent
):
    sender_id = "test_logging_of_bot_utterances_on_tracker"
    tracker = default_agent.tracker_store.get_or_create_tracker(sender_id)
    buttons = [
        Button(title="Btn1", payload="_btn1"),
        Button(title="Btn2", payload="_btn2"),
    ]

    await default_dispatcher_collecting.utter_template("utter_goodbye", tracker)
    await default_dispatcher_collecting.utter_attachment("http://my-attachment")
    await default_dispatcher_collecting.utter_message("my test message")
    await default_dispatcher_collecting.utter_button_message("my message", buttons)

    assert len(default_dispatcher_collecting.latest_bot_messages) == 4

    default_processor.log_bot_utterances_on_tracker(
        tracker, default_dispatcher_collecting
    )
    assert not default_dispatcher_collecting.latest_bot_messages