Add tests for optional args with empty input

This commit is contained in:
Kay0u 2020-11-25 10:41:20 +01:00
parent 67e03e6f1b
commit 6a550f9318
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D

View file

@ -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 = {}