mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Add tests for optional args with empty input
This commit is contained in:
parent
67e03e6f1b
commit
6a550f9318
1 changed files with 52 additions and 0 deletions
|
@ -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
|
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():
|
def test_parse_args_in_yunohost_format_string_optional_with_input_without_ask():
|
||||||
questions = [{"name": "some_string", "optional": True, }]
|
questions = [{"name": "some_string", "optional": True, }]
|
||||||
answers = {}
|
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
|
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():
|
def test_parse_args_in_yunohost_format_password_optional_with_input_without_ask():
|
||||||
questions = [{"name": "some_password", "type": "password", "optional": True, }]
|
questions = [{"name": "some_password", "type": "password", "optional": True, }]
|
||||||
answers = {}
|
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
|
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():
|
def test_parse_args_in_yunohost_format_path_optional_with_input_without_ask():
|
||||||
questions = [{"name": "some_path", "type": "path", "optional": True, }]
|
questions = [{"name": "some_path", "type": "path", "optional": True, }]
|
||||||
answers = {}
|
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
|
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():
|
def test_parse_args_in_yunohost_format_boolean_optional_with_input_without_ask():
|
||||||
questions = [{"name": "some_boolean", "type": "boolean", "optional": True, }]
|
questions = [{"name": "some_boolean", "type": "boolean", "optional": True, }]
|
||||||
answers = {}
|
answers = {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue