def test_convo_params_are_cleared(kwik_e_mart_nlp, kwik_e_mart_app_path): """Tests that the params are cleared in one trip from app to mm.""" convo = Conversation(nlp=kwik_e_mart_nlp, app_path=kwik_e_mart_app_path) convo.params = Params(allowed_intents=['store_info.find_nearest_store'], target_dialogue_state='greeting') convo.say('close door') assert convo.params == Params()
async def test_convo_params_are_cleared(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) convo.params = Params( allowed_intents=["store_info.find_nearest_store"], target_dialogue_state="welcome", ) await convo.say("close door") assert convo.params == Params()
def test_convo_language_and_locales(mocker, kwik_e_mart_nlp, kwik_e_mart_app_path, language, locale, expected_ser_call): """Tests that the params are cleared in one trip from app to mm.""" convo = Conversation(nlp=kwik_e_mart_nlp, app_path=kwik_e_mart_app_path) convo.params = Params(language=language, locale=locale) mock1 = mocker.patch.object(DucklingRecognizer, "get_response", return_value=({}, 400)) convo.say("set alarm for 4pm tomorrow") mock1.call_args_list[0][0][0].pop("text") assert mock1.call_args_list[0][0][0] == expected_ser_call
def test_convo_language_and_locales(mocker, kwik_e_mart_nlp, kwik_e_mart_app_path, language, locale, expected_ser_call): """Tests that the params are cleared in one trip from app to mm.""" convo = Conversation(nlp=kwik_e_mart_nlp, app_path=kwik_e_mart_app_path) convo.params = Params(language=language, locale=locale) mock1 = mocker.patch.object(DucklingRecognizer, "get_response", return_value=({}, 400)) try: convo.say("set alarm for 4pm tomorrow") mock1.call_args_list[0][0][0].pop("text") assert mock1.call_args_list[0][0][0] == expected_ser_call except ValidationError as error: if isinstance(error.messages, dict): if language == 'INVALID_LANG_CODE': assert 'Invalid language param: invalid_lang_code is not a valid ' \ 'ISO 639-1 or ISO 639-2 language code.' in str(error.messages) elif locale == 'INVALID_LOCALE_CODE': assert 'Invalid locale param: invalid_locale_code is not a valid ' \ 'ISO 639-1 or ISO 639-2 language code.' in str(error.messages) else: assert error.messages[0] == "Invalid locale_code param: %s is " \ "not a valid locale." % locale