From e41d6186eee6cc76c2304d30b8a1afacac28ca52 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 16 May 2020 01:59:28 +0200 Subject: [PATCH] [mod] and more tests --- .../tests/test_apps_arguments_parsing.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/yunohost/tests/test_apps_arguments_parsing.py b/src/yunohost/tests/test_apps_arguments_parsing.py index c92007873..1b155656f 100644 --- a/src/yunohost/tests/test_apps_arguments_parsing.py +++ b/src/yunohost/tests/test_apps_arguments_parsing.py @@ -195,3 +195,26 @@ def test_parse_args_in_yunohost_format_string_input_test_ask_with_help(): _parse_args_in_yunohost_format(answers, questions) assert ask_text in prompt.call_args[0] assert help_text in prompt.call_args[0] + + +def test_parse_args_in_yunohost_format_string_with_choice(): + questions = [{ + "name": "some_string", + "type": "string", + "choices": ["fr", "en"] + }] + answers = {"some_string": "fr"} + expected_result = OrderedDict({"some_string": ("fr", "string")}) + assert _parse_args_in_yunohost_format(answers, questions) == expected_result + + +def test_parse_args_in_yunohost_format_string_with_choice_bad(): + questions = [{ + "name": "some_string", + "type": "string", + "choices": ["fr", "en"] + }] + answers = {"some_string": "bad"} + + with pytest.raises(YunohostError): + assert _parse_args_in_yunohost_format(answers, questions)