diff --git a/src/yunohost/tests/test_apps_arguments_parsing.py b/src/yunohost/tests/test_apps_arguments_parsing.py index 598eb9eec..5edd450d8 100644 --- a/src/yunohost/tests/test_apps_arguments_parsing.py +++ b/src/yunohost/tests/test_apps_arguments_parsing.py @@ -95,6 +95,15 @@ def test_parse_args_in_yunohost_format_string_optional_with_input(): assert _parse_args_in_yunohost_format(answers, questions) == expected_result +def test_parse_args_in_yunohost_format_string_optional_with_empty_input(): + questions = [{"name": "some_string", "ask": "some question", "optional": True, }] + answers = {} + expected_result = OrderedDict({"some_string": ("", "string")}) + + with patch.object(msignals, "prompt", return_value=""): + assert _parse_args_in_yunohost_format(answers, questions) == expected_result + + def test_parse_args_in_yunohost_format_string_optional_with_input_without_ask(): questions = [{"name": "some_string", "optional": True, }] answers = {} @@ -268,6 +277,22 @@ def test_parse_args_in_yunohost_format_password_optional_with_input(): assert _parse_args_in_yunohost_format(answers, questions) == expected_result +def test_parse_args_in_yunohost_format_password_optional_with_empty_input(): + questions = [ + { + "name": "some_password", + "ask": "some question", + "type": "password", + "optional": True, + } + ] + answers = {} + expected_result = OrderedDict({"some_password": ("", "password")}) + + with patch.object(msignals, "prompt", return_value=""): + assert _parse_args_in_yunohost_format(answers, questions) == expected_result + + def test_parse_args_in_yunohost_format_password_optional_with_input_without_ask(): questions = [{"name": "some_password", "type": "password", "optional": True, }] answers = {} @@ -444,6 +469,17 @@ def test_parse_args_in_yunohost_format_path_optional_with_input(): assert _parse_args_in_yunohost_format(answers, questions) == expected_result +def test_parse_args_in_yunohost_format_path_optional_with_empty_input(): + questions = [ + {"name": "some_path", "ask": "some question", "type": "path", "optional": True, } + ] + answers = {} + expected_result = OrderedDict({"some_path": ("", "path")}) + + with patch.object(msignals, "prompt", return_value=""): + assert _parse_args_in_yunohost_format(answers, questions) == expected_result + + def test_parse_args_in_yunohost_format_path_optional_with_input_without_ask(): questions = [{"name": "some_path", "type": "path", "optional": True, }] answers = {} @@ -663,6 +699,22 @@ def test_parse_args_in_yunohost_format_boolean_optional_with_input(): assert _parse_args_in_yunohost_format(answers, questions) == expected_result +def test_parse_args_in_yunohost_format_boolean_optional_with_empty_input(): + questions = [ + { + "name": "some_boolean", + "ask": "some question", + "type": "boolean", + "optional": True, + } + ] + answers = {} + expected_result = OrderedDict({"some_boolean": (0, "boolean")}) + + with patch.object(msignals, "prompt", return_value=""): + assert _parse_args_in_yunohost_format(answers, questions) == expected_result + + def test_parse_args_in_yunohost_format_boolean_optional_with_input_without_ask(): questions = [{"name": "some_boolean", "type": "boolean", "optional": True, }] answers = {}