Ejemplo n.º 1
0
def test_guide_reenter():
    handler = MessageHandler({"scrum"})
    response = send_message(handler, "What is Scrum about?", "test_session")
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 2
    assert response['dialogue'][0]['action_type'] == "explain"
    assert response['dialogue'][0]['action_name'] == "explain"
    assert response['dialogue'][1]['action_type'] == "continue"
    assert response['dialogue'][1]['action_name'] == "continue"

    response = send_message(handler, "Yes", "test_session")
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 2
    assert response['dialogue'][0]['action_type'] == "explain"
    assert response['dialogue'][0]['action_name'] == "explain"
    assert response['dialogue'][1]['action_type'] == "continue"
    assert response['dialogue'][1]['action_name'] == "continue"

    response = send_message(handler, "No", "test_session")
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 0

    response = send_message(
        handler, "Yes",
        "test_session")  # TODO This input will mess up the dialogue
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 0
Ejemplo n.º 2
0
def test_details():
    handler = MessageHandler({"scrum"})
    response = send_message(handler, "What is Scrum about?", "test_session")
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 2

    # Explain
    theme = get_first_theme()
    assert response['dialogue'][0]['action_type'] == "explain"
    assert response['dialogue'][0]['action_name'] == "explain"
    assert response['dialogue'][0]['title'] == theme
    assert response['dialogue'][0]['content'] == dict.scrum[theme]['general']
    if 'replyOptions' in response['dialogue'][0]:
        assert reply_options_contain_details(
            response['dialogue'][0]['replyOptions'],
            dict.scrum[theme]['details'])

    # Continue
    theme = get_next_theme(theme)
    assert response['dialogue'][1]['action_type'] == "continue"
    assert response['dialogue'][1]['action_name'] == "continue"
    assert response['dialogue'][1]['content'].endswith(theme + '?')
    assert response['dialogue'][1]['replyOptions'] == [{
        "text": "yes",
        "reply": "yes"
    }]

    detail = "agile"
    response = send_message(handler, "Tell me more about " + detail,
                            "test_session")
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 2

    # Explain Detail
    theme = get_first_theme()
    assert response['dialogue'][0]['action_type'] == "explain"
    assert response['dialogue'][0]['action_name'] == "explain_detail"
    assert response['dialogue'][0]['title'] == detail
    assert response['dialogue'][0]['content'] == dict.scrum[theme]['details'][
        detail]
    if 'replyOptions' in response['dialogue'][0]:
        assert reply_options_contain_details(
            response['dialogue'][0]['replyOptions'],
            filter_details(theme, detail))

    # Continue
    theme = get_next_theme(theme)
    assert response['dialogue'][1]['action_type'] == "continue"
    assert response['dialogue'][1]['action_name'] == "continue"
    assert response['dialogue'][1]['content'].endswith(theme + '?')
    assert response['dialogue'][1]['replyOptions'] == [{
        "text": "yes",
        "reply": "yes"
    }]
Ejemplo n.º 3
0
def perform_inform(inform_input):
    handler = MessageHandler({"scrum"})
    send_message(handler, "What is Scrum about?", "test_session")

    response = send_message(handler, inform_input, "test_session")
    return response['nlu']
Ejemplo n.º 4
0
def perform_single_continue(continue_input):
    handler = MessageHandler({"scrum"})
    send_message(handler, "What is Scrum about?", "test_session")

    response = send_message(handler, continue_input, "test_session")
    return response['nlu']
Ejemplo n.º 5
0
def perform_initial_input(initial_input):
    handler = MessageHandler({"scrum"})
    response = send_message(handler, initial_input, "test_session")
    return response['nlu']
Ejemplo n.º 6
0
def test_guide_restart():
    handler = MessageHandler({"scrum"})
    response = send_message(handler, "What is Scrum about?", "test_session")
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 2

    # Explain
    theme = get_first_theme()
    assert response['dialogue'][0]['action_type'] == "explain"
    assert response['dialogue'][0]['action_name'] == "explain"
    assert response['dialogue'][0]['title'] == theme
    assert response['dialogue'][0]['content'] == dict.scrum[theme]['general']
    if 'replyOptions' in response['dialogue'][0]:
        assert reply_options_contain_details(
            response['dialogue'][0]['replyOptions'],
            dict.scrum[theme]['details'])

    # Continue
    theme = get_next_theme(theme)
    assert response['dialogue'][1]['action_type'] == "continue"
    assert response['dialogue'][1]['action_name'] == "continue"
    assert response['dialogue'][1]['content'].endswith(theme + '?')
    assert response['dialogue'][1]['replyOptions'] == [{
        "text": "yes",
        "reply": "yes"
    }]

    response = send_message(handler, "Yes", "test_session")
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 2

    # Explain
    assert response['dialogue'][0]['action_type'] == "explain"
    assert response['dialogue'][0]['action_name'] == "explain"
    assert response['dialogue'][0]['title'] == theme
    assert response['dialogue'][0]['content'] == dict.scrum[theme]['general']
    if 'replyOptions' in response['dialogue'][0]:
        assert reply_options_contain_details(
            response['dialogue'][0]['replyOptions'],
            dict.scrum[theme]['details'])

    # Continue
    theme = get_next_theme(theme)
    assert response['dialogue'][1]['action_type'] == "continue"
    assert response['dialogue'][1]['action_name'] == "continue"
    assert response['dialogue'][1]['content'].endswith(theme + '?')
    assert response['dialogue'][1]['replyOptions'] == [{
        "text": "yes",
        "reply": "yes"
    }]

    response = send_message(handler, "No", "test_session")
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 0

    response = send_message(handler, "What is Scrum about?", "test_session")
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 2

    # Explain
    theme = get_first_theme()
    assert response['dialogue'][0]['action_type'] == "explain"
    assert response['dialogue'][0]['action_name'] == "explain"
    assert response['dialogue'][0]['title'] == theme
    assert response['dialogue'][0]['content'] == dict.scrum[theme]['general']
    if 'replyOptions' in response['dialogue'][0]:
        assert reply_options_contain_details(
            response['dialogue'][0]['replyOptions'],
            dict.scrum[theme]['details'])

    # Continue
    theme = get_next_theme(theme)
    assert response['dialogue'][1]['action_type'] == "continue"
    assert response['dialogue'][1]['action_name'] == "continue"
    assert response['dialogue'][1]['content'].endswith(theme + '?')
    assert response['dialogue'][1]['replyOptions'] == [{
        "text": "yes",
        "reply": "yes"
    }]
Ejemplo n.º 7
0
def test_guide_endless():
    handler = MessageHandler({"scrum"})
    response = send_message(handler, "What is Scrum about?", "test_session")
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 2

    # Explain
    theme = get_first_theme()
    assert response['dialogue'][0]['action_type'] == "explain"
    assert response['dialogue'][0]['action_name'] == "explain"
    assert response['dialogue'][0]['title'] == theme
    assert response['dialogue'][0]['content'] == dict.scrum[theme]['general']
    assert reply_options_contain_details(
        response['dialogue'][0]['replyOptions'], dict.scrum[theme]['details'])

    # Continue
    theme = get_next_theme(theme)
    assert response['dialogue'][1]['action_type'] == "continue"
    assert response['dialogue'][1]['action_name'] == "continue"
    assert response['dialogue'][1]['content'].endswith(theme + '?')
    assert response['dialogue'][1]['replyOptions'] == [{
        "text": "yes",
        "reply": "yes"
    }]

    for i in range(0, len(dict.scrum) - 2):
        response = send_message(handler, "Yes", "test_session")
        assert response['sender'] == "test_session"
        assert len(response['dialogue']) == 2

        # Explain
        assert response['dialogue'][0]['action_type'] == "explain"
        assert response['dialogue'][0]['action_name'] == "explain"
        assert response['dialogue'][0]['title'] == theme
        assert response['dialogue'][0]['content'] == dict.scrum[theme][
            'general']
        if 'replyOptions' in response['dialogue'][0]:
            assert reply_options_contain_details(
                response['dialogue'][0]['replyOptions'],
                dict.scrum[theme]['details'])

        # Continue
        theme = get_next_theme(theme)
        assert response['dialogue'][1]['action_type'] == "continue"
        assert response['dialogue'][1]['action_name'] == "continue"
        assert response['dialogue'][1]['content'].endswith(theme + '?')
        assert response['dialogue'][1]['replyOptions'] == [{
            "text": "yes",
            "reply": "yes"
        }]

    response = send_message(handler, "Yes", "test_session")
    assert response['sender'] == "test_session"
    assert len(response['dialogue']) == 2

    # Explain
    assert response['dialogue'][0]['action_type'] == "explain"
    assert response['dialogue'][0]['action_name'] == "explain"
    assert response['dialogue'][0]['title'] == theme
    assert response['dialogue'][0]['content'] == dict.scrum[theme]['general']
    if 'replyOptions' in response['dialogue'][0]:
        assert reply_options_contain_details(
            response['dialogue'][0]['replyOptions'],
            dict.scrum[theme]['details'])

    # Continue
    assert response['dialogue'][1]['action_type'] == "continue"
    assert response['dialogue'][1]['action_name'] == "continue"
    assert response['dialogue'][1][
        'content'] == 'That is it for the crash course in scrum. Would you like to restart?'
    assert response['dialogue'][1]['replyOptions'] == [{
        "text": "yes",
        "reply": "yes"
    }]