Exemplo n.º 1
0
def test_auto_fill_happy_path_validation(kwik_e_mart_app, qa_kwik_e_mart):
    """Tests a happy path for the app with gazetter validation."""
    convo = Conversation(app=kwik_e_mart_app)
    directives = convo.process("What's the store phone number?").directives
    assert_target_dialogue_state(convo, "send_store_phone")
    assert_reply(directives, "Which store would you like to know about?")

    convo.process("the store on elm street")
    assert_target_dialogue_state(convo, None)
Exemplo n.º 2
0
def test_auto_fill_exit_flow(kwik_e_mart_app, qa_kwik_e_mart):
    """Tests slot-fill exit flow logic."""
    convo = Conversation(app=kwik_e_mart_app)
    directives = convo.process("What's the store phone number?").directives
    assert_target_dialogue_state(convo, "send_store_phone")
    assert_reply(directives, "Which store would you like to know about?")

    directives = convo.process("exit").directives
    assert_reply(directives, "Sorry I cannot help you. Please try again.")
    assert_target_dialogue_state(convo, None)
Exemplo n.º 3
0
def test_intent_handler_and_exit_flow(async_kwik_e_mart_app,
                                      kwik_e_mart_app_path):
    """Tests that the params are cleared in one trip from app to mm."""
    convo = Conversation(app=async_kwik_e_mart_app,
                         app_path=kwik_e_mart_app_path,
                         force_sync=True)
    convo.process("When does that open?")
    assert_target_dialogue_state(convo, "send_store_hours_flow")
    directives = convo.process("exit").directives
    assert_target_dialogue_state(convo, None)
    assert_reply(directives, templates=["Bye", "Goodbye", "Have a nice day."])
Exemplo n.º 4
0
def test_reprocess_handler(async_kwik_e_mart_app, kwik_e_mart_app_path):
    """Tests that the params are cleared in one trip from app to mm."""
    convo = Conversation(app=async_kwik_e_mart_app,
                         app_path=kwik_e_mart_app_path,
                         force_sync=True)
    convo.process("When does that open?")
    assert_target_dialogue_state(convo, "send_store_hours_flow")
    directives = convo.process("are there any stores near me?").directives
    assert_target_dialogue_state(convo, "send_store_hours_flow")
    assert_reply(directives,
                 templates="I'm not sure. You haven't told me where you are!")
Exemplo n.º 5
0
def test_auto_fill_happy_path(kwik_e_mart_app, kwik_e_mart_app_path, qa_kwik_e_mart):
    """Tests that the params are cleared in one trip from app to mm."""
    convo = Conversation(
        app=kwik_e_mart_app, app_path=kwik_e_mart_app_path, force_sync=True
    )
    directives = convo.process("What's the store phone number?").directives
    assert_target_dialogue_state(convo, "send_store_phone")
    assert_reply(directives, "Which store would you like to know about?")

    directives = convo.process("elm street").directives
    assert_target_dialogue_state(convo, None)
Exemplo n.º 6
0
def test_auto_fill_exit_flow(kwik_e_mart_app, kwik_e_mart_app_path):
    """Tests that the params are cleared in one trip from app to mm."""
    convo = Conversation(
        app=kwik_e_mart_app, app_path=kwik_e_mart_app_path, force_sync=True
    )
    directives = convo.process("What's the store phone number?").directives
    assert_target_dialogue_state(convo, "send_store_phone")
    assert_reply(directives, "Which store would you like to know about?")

    directives = convo.process("exit").directives
    assert_reply(directives, "Sorry I cannot help you. Please try again.")
    assert_target_dialogue_state(convo, None)
Exemplo n.º 7
0
def test_auto_fill_validation_missing_entities(kwik_e_mart_app, qa_kwik_e_mart):
    """Tests default validation when user input has no entities.
    Check is to see that flow doesn't break."""
    convo = Conversation(app=kwik_e_mart_app)
    directives = convo.process("What's the store phone number?").directives
    assert_target_dialogue_state(convo, "send_store_phone")
    assert_reply(directives, "Which store would you like to know about?")

    directives = convo.process("123").directives
    assert_reply(
        directives,
        "Sorry, I did not get you. " "Which store would you like to know about?",
    )
Exemplo n.º 8
0
def test_default_handler(async_kwik_e_mart_app, kwik_e_mart_app_path):
    """Tests that the params are cleared in one trip from app to mm."""
    convo = Conversation(app=async_kwik_e_mart_app,
                         app_path=kwik_e_mart_app_path,
                         force_sync=True)
    convo.process('When does that open?')
    assert_target_dialogue_state(convo, 'send_store_hours_flow')
    directives = convo.process('are there any stores near me?').directives
    assert_target_dialogue_state(convo, 'send_store_hours_flow')
    assert_reply(
        directives,
        templates=
        'Sorry, I did not get you. Which store would you like to know about?')
Exemplo n.º 9
0
def test_repeated_flow(async_kwik_e_mart_app, kwik_e_mart_app_path):
    """Tests that the params are cleared in one trip from app to mm."""
    convo = Conversation(app=async_kwik_e_mart_app,
                         app_path=kwik_e_mart_app_path,
                         force_sync=True)
    convo.process("When does that open?")
    assert_target_dialogue_state(convo, "send_store_hours_flow")
    for i in range(2):
        directives = convo.process("When does that open?").directives
        assert_reply(directives, "Which store would you like to know about?")
        assert_target_dialogue_state(convo, "send_store_hours_flow")
    directives = convo.process("When does that open?").directives
    assert_reply(directives, "Sorry I cannot help you. Please try again.")
    assert_target_dialogue_state(convo, None)
Exemplo n.º 10
0
def test_auto_fill_switch_flow(kwik_e_mart_app, qa_kwik_e_mart):
    """Tests flow switching from inside slot filling to another intent when
    the number of retry attempts are exceeded."""
    convo = Conversation(app=kwik_e_mart_app)
    directives = convo.process("What's the store phone number?").directives
    assert_target_dialogue_state(convo, "send_store_phone")
    assert_reply(directives, "Which store would you like to know about?")

    directives = convo.process("goodbye").directives
    assert_reply(
        directives,
        "Sorry, I did not get you. " "Which store would you like to know about?",
    )

    directives = convo.process("goodbye").directives
    assert_reply(directives, ["Bye", "Goodbye", "Have a nice day."])
Exemplo n.º 11
0
def test_auto_fill_retry(kwik_e_mart_app, qa_kwik_e_mart):
    """Tests that the retry logic for slots/entities."""
    convo = Conversation(app=kwik_e_mart_app)
    directives = convo.process("What's the store phone number?").directives
    assert_target_dialogue_state(convo, "send_store_phone")
    assert_reply(directives, "Which store would you like to know about?")

    directives = convo.process("Some store").directives
    assert_target_dialogue_state(convo, "send_store_phone")
    assert_reply(
        directives,
        "Sorry, I did not get you. " "Which store would you like to know about?",
    )

    convo.process("elm street")
    assert_target_dialogue_state(convo, None)
Exemplo n.º 12
0
def test_convo_force_sync_invocation(async_kwik_e_mart_app, kwik_e_mart_app_path):
    """Tests that force sync kwarg works correctly when passed to convo
    at invocation.
    """
    convo = Conversation(app=async_kwik_e_mart_app, app_path=kwik_e_mart_app_path)

    response = convo.process('close door', force_sync=True)

    assert isinstance(response, DialogueResponder)