[mod] black file

This commit is contained in:
Laurent Peuch 2020-05-17 02:04:50 +02:00
parent e181866dca
commit 69f8ab1ac4

View file

@ -36,28 +36,21 @@ def test_parse_args_in_yunohost_format_empty():
def test_parse_args_in_yunohost_format_string():
questions = [{
"name": "some_string",
"type": "string",
}]
questions = [{"name": "some_string", "type": "string",}]
answers = {"some_string": "some_value"}
expected_result = OrderedDict({"some_string": ("some_value", "string")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_string_default_type():
questions = [{
"name": "some_string",
}]
questions = [{"name": "some_string",}]
answers = {"some_string": "some_value"}
expected_result = OrderedDict({"some_string": ("some_value", "string")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_string_no_input():
questions = [{
"name": "some_string",
}]
questions = [{"name": "some_string",}]
answers = {}
with pytest.raises(YunohostError):
@ -65,10 +58,7 @@ def test_parse_args_in_yunohost_format_string_no_input():
def test_parse_args_in_yunohost_format_string_input():
questions = [{
"name": "some_string",
"ask": "some question",
}]
questions = [{"name": "some_string", "ask": "some question",}]
answers = {}
expected_result = OrderedDict({"some_string": ("some_value", "string")})
@ -78,9 +68,7 @@ def test_parse_args_in_yunohost_format_string_input():
@pytest.mark.skip # that shit should work x(
def test_parse_args_in_yunohost_format_string_input_no_ask():
questions = [{
"name": "some_string",
}]
questions = [{"name": "some_string",}]
answers = {}
expected_result = OrderedDict({"some_string": ("some_value", "string")})
@ -89,21 +77,14 @@ def test_parse_args_in_yunohost_format_string_input_no_ask():
def test_parse_args_in_yunohost_format_string_no_input_optional():
questions = [{
"name": "some_string",
"optional": True,
}]
questions = [{"name": "some_string", "optional": True,}]
answers = {}
expected_result = OrderedDict({"some_string": ("", "string")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_string_optional_with_input():
questions = [{
"name": "some_string",
"ask": "some question",
"optional": True,
}]
questions = [{"name": "some_string", "ask": "some question", "optional": True,}]
answers = {}
expected_result = OrderedDict({"some_string": ("some_value", "string")})
@ -113,10 +94,7 @@ def test_parse_args_in_yunohost_format_string_optional_with_input():
@pytest.mark.skip # this should work 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 = {}
expected_result = OrderedDict({"some_string": ("some_value", "string")})
@ -125,11 +103,9 @@ def test_parse_args_in_yunohost_format_string_optional_with_input_without_ask():
def test_parse_args_in_yunohost_format_string_no_input_default():
questions = [{
"name": "some_string",
"ask": "some question",
"default": "some_value",
}]
questions = [
{"name": "some_string", "ask": "some question", "default": "some_value",}
]
answers = {}
expected_result = OrderedDict({"some_string": ("some_value", "string")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
@ -137,10 +113,7 @@ def test_parse_args_in_yunohost_format_string_no_input_default():
def test_parse_args_in_yunohost_format_string_input_test_ask():
ask_text = "some question"
questions = [{
"name": "some_string",
"ask": ask_text,
}]
questions = [{"name": "some_string", "ask": ask_text,}]
answers = {}
with patch.object(msignals, "prompt", return_value="some_value") as prompt:
@ -151,11 +124,7 @@ def test_parse_args_in_yunohost_format_string_input_test_ask():
def test_parse_args_in_yunohost_format_string_input_test_ask_with_default():
ask_text = "some question"
default_text = "some example"
questions = [{
"name": "some_string",
"ask": ask_text,
"default": default_text,
}]
questions = [{"name": "some_string", "ask": ask_text, "default": default_text,}]
answers = {}
with patch.object(msignals, "prompt", return_value="some_value") as prompt:
@ -167,11 +136,7 @@ def test_parse_args_in_yunohost_format_string_input_test_ask_with_default():
def test_parse_args_in_yunohost_format_string_input_test_ask_with_example():
ask_text = "some question"
example_text = "some example"
questions = [{
"name": "some_string",
"ask": ask_text,
"example": example_text,
}]
questions = [{"name": "some_string", "ask": ask_text, "example": example_text,}]
answers = {}
with patch.object(msignals, "prompt", return_value="some_value") as prompt:
@ -184,11 +149,7 @@ def test_parse_args_in_yunohost_format_string_input_test_ask_with_example():
def test_parse_args_in_yunohost_format_string_input_test_ask_with_help():
ask_text = "some question"
help_text = "some_help"
questions = [{
"name": "some_string",
"ask": ask_text,
"help": help_text,
}]
questions = [{"name": "some_string", "ask": ask_text, "help": help_text,}]
answers = {}
with patch.object(msignals, "prompt", return_value="some_value") as prompt:
@ -198,22 +159,14 @@ def test_parse_args_in_yunohost_format_string_input_test_ask_with_help():
def test_parse_args_in_yunohost_format_string_with_choice():
questions = [{
"name": "some_string",
"type": "string",
"choices": ["fr", "en"]
}]
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_prompt():
questions = [{
"name": "some_string",
"type": "string",
"choices": ["fr", "en"]
}]
questions = [{"name": "some_string", "type": "string", "choices": ["fr", "en"]}]
answers = {"some_string": "fr"}
expected_result = OrderedDict({"some_string": ("fr", "string")})
with patch.object(msignals, "prompt", return_value="fr"):
@ -221,11 +174,7 @@ def test_parse_args_in_yunohost_format_string_with_choice_prompt():
def test_parse_args_in_yunohost_format_string_with_choice_bad():
questions = [{
"name": "some_string",
"type": "string",
"choices": ["fr", "en"]
}]
questions = [{"name": "some_string", "type": "string", "choices": ["fr", "en"]}]
answers = {"some_string": "bad"}
with pytest.raises(YunohostError):
@ -235,11 +184,7 @@ def test_parse_args_in_yunohost_format_string_with_choice_bad():
def test_parse_args_in_yunohost_format_string_with_choice_ask():
ask_text = "some question"
choices = ["fr", "en", "es", "it", "ru"]
questions = [{
"name": "some_string",
"ask": ask_text,
"choices": choices,
}]
questions = [{"name": "some_string", "ask": ask_text, "choices": choices,}]
answers = {}
with patch.object(msignals, "prompt", return_value="ru") as prompt:
@ -251,32 +196,28 @@ def test_parse_args_in_yunohost_format_string_with_choice_ask():
def test_parse_args_in_yunohost_format_string_with_choice_default():
questions = [{
"name": "some_string",
"type": "string",
"choices": ["fr", "en"],
"default": "en",
}]
questions = [
{
"name": "some_string",
"type": "string",
"choices": ["fr", "en"],
"default": "en",
}
]
answers = {}
expected_result = OrderedDict({"some_string": ("en", "string")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_password():
questions = [{
"name": "some_password",
"type": "password",
}]
questions = [{"name": "some_password", "type": "password",}]
answers = {"some_password": "some_value"}
expected_result = OrderedDict({"some_password": ("some_value", "password")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_password_no_input():
questions = [{
"name": "some_password",
"type": "password",
}]
questions = [{"name": "some_password", "type": "password",}]
answers = {}
with pytest.raises(YunohostError):
@ -284,11 +225,7 @@ def test_parse_args_in_yunohost_format_password_no_input():
def test_parse_args_in_yunohost_format_password_input():
questions = [{
"name": "some_password",
"type": "password",
"ask": "some question",
}]
questions = [{"name": "some_password", "type": "password", "ask": "some question",}]
answers = {}
expected_result = OrderedDict({"some_password": ("some_value", "password")})
@ -298,10 +235,7 @@ def test_parse_args_in_yunohost_format_password_input():
@pytest.mark.skip # that shit should work x(
def test_parse_args_in_yunohost_format_password_input_no_ask():
questions = [{
"name": "some_password",
"type": "password",
}]
questions = [{"name": "some_password", "type": "password",}]
answers = {}
expected_result = OrderedDict({"some_password": ("some_value", "password")})
@ -310,23 +244,21 @@ def test_parse_args_in_yunohost_format_password_input_no_ask():
def test_parse_args_in_yunohost_format_password_no_input_optional():
questions = [{
"name": "some_password",
"type": "password",
"optional": True,
}]
questions = [{"name": "some_password", "type": "password", "optional": True,}]
answers = {}
expected_result = OrderedDict({"some_password": ("", "password")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_password_optional_with_input():
questions = [{
"name": "some_password",
"ask": "some question",
"type": "password",
"optional": True,
}]
questions = [
{
"name": "some_password",
"ask": "some question",
"type": "password",
"optional": True,
}
]
answers = {}
expected_result = OrderedDict({"some_password": ("some_value", "password")})
@ -336,11 +268,7 @@ def test_parse_args_in_yunohost_format_password_optional_with_input():
@pytest.mark.skip # this should work 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 = {}
expected_result = OrderedDict({"some_password": ("some_value", "password")})
@ -350,12 +278,14 @@ def test_parse_args_in_yunohost_format_password_optional_with_input_without_ask(
@pytest.mark.skip # this should raises
def test_parse_args_in_yunohost_format_password_no_input_default():
questions = [{
"name": "some_password",
"type": "password",
"ask": "some question",
"default": "some_value",
}]
questions = [
{
"name": "some_password",
"type": "password",
"ask": "some question",
"default": "some_value",
}
]
answers = {}
# no default for password!
@ -365,12 +295,14 @@ def test_parse_args_in_yunohost_format_password_no_input_default():
@pytest.mark.skip # this should raises
def test_parse_args_in_yunohost_format_password_no_input_example():
questions = [{
"name": "some_password",
"type": "password",
"ask": "some question",
"example": "some_value",
}]
questions = [
{
"name": "some_password",
"type": "password",
"ask": "some question",
"example": "some_value",
}
]
answers = {"some_password": "some_value"}
# no example for password!
@ -380,11 +312,7 @@ def test_parse_args_in_yunohost_format_password_no_input_example():
def test_parse_args_in_yunohost_format_password_input_test_ask():
ask_text = "some question"
questions = [{
"name": "some_password",
"type": "password",
"ask": ask_text,
}]
questions = [{"name": "some_password", "type": "password", "ask": ask_text,}]
answers = {}
with patch.object(msignals, "prompt", return_value="some_value") as prompt:
@ -396,12 +324,14 @@ def test_parse_args_in_yunohost_format_password_input_test_ask():
def test_parse_args_in_yunohost_format_password_input_test_ask_with_example():
ask_text = "some question"
example_text = "some example"
questions = [{
"name": "some_password",
"type": "password",
"ask": ask_text,
"example": example_text,
}]
questions = [
{
"name": "some_password",
"type": "password",
"ask": ask_text,
"example": example_text,
}
]
answers = {}
with patch.object(msignals, "prompt", return_value="some_value") as prompt:
@ -414,12 +344,14 @@ def test_parse_args_in_yunohost_format_password_input_test_ask_with_example():
def test_parse_args_in_yunohost_format_password_input_test_ask_with_help():
ask_text = "some question"
help_text = "some_help"
questions = [{
"name": "some_password",
"type": "password",
"ask": ask_text,
"help": help_text,
}]
questions = [
{
"name": "some_password",
"type": "password",
"ask": ask_text,
"help": help_text,
}
]
answers = {}
with patch.object(msignals, "prompt", return_value="some_value") as prompt:
@ -429,20 +361,14 @@ def test_parse_args_in_yunohost_format_password_input_test_ask_with_help():
def test_parse_args_in_yunohost_format_path():
questions = [{
"name": "some_path",
"type": "path",
}]
questions = [{"name": "some_path", "type": "path",}]
answers = {"some_path": "some_value"}
expected_result = OrderedDict({"some_path": ("some_value", "path")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_path_no_input():
questions = [{
"name": "some_path",
"type": "path",
}]
questions = [{"name": "some_path", "type": "path",}]
answers = {}
with pytest.raises(YunohostError):
@ -450,11 +376,7 @@ def test_parse_args_in_yunohost_format_path_no_input():
def test_parse_args_in_yunohost_format_path_input():
questions = [{
"name": "some_path",
"type": "path",
"ask": "some question",
}]
questions = [{"name": "some_path", "type": "path", "ask": "some question",}]
answers = {}
expected_result = OrderedDict({"some_path": ("some_value", "path")})
@ -464,10 +386,7 @@ def test_parse_args_in_yunohost_format_path_input():
@pytest.mark.skip # that shit should work x(
def test_parse_args_in_yunohost_format_path_input_no_ask():
questions = [{
"name": "some_path",
"type": "path",
}]
questions = [{"name": "some_path", "type": "path",}]
answers = {}
expected_result = OrderedDict({"some_path": ("some_value", "path")})
@ -476,23 +395,16 @@ def test_parse_args_in_yunohost_format_path_input_no_ask():
def test_parse_args_in_yunohost_format_path_no_input_optional():
questions = [{
"name": "some_path",
"type": "path",
"optional": True,
}]
questions = [{"name": "some_path", "type": "path", "optional": True,}]
answers = {}
expected_result = OrderedDict({"some_path": ("", "path")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_path_optional_with_input():
questions = [{
"name": "some_path",
"ask": "some question",
"type": "path",
"optional": True,
}]
questions = [
{"name": "some_path", "ask": "some question", "type": "path", "optional": True,}
]
answers = {}
expected_result = OrderedDict({"some_path": ("some_value", "path")})
@ -502,11 +414,7 @@ def test_parse_args_in_yunohost_format_path_optional_with_input():
@pytest.mark.skip # this should work 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 = {}
expected_result = OrderedDict({"some_path": ("some_value", "path")})
@ -515,12 +423,14 @@ def test_parse_args_in_yunohost_format_path_optional_with_input_without_ask():
def test_parse_args_in_yunohost_format_path_no_input_default():
questions = [{
"name": "some_path",
"ask": "some question",
"type": "path",
"default": "some_value",
}]
questions = [
{
"name": "some_path",
"ask": "some question",
"type": "path",
"default": "some_value",
}
]
answers = {}
expected_result = OrderedDict({"some_path": ("some_value", "path")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
@ -528,11 +438,7 @@ def test_parse_args_in_yunohost_format_path_no_input_default():
def test_parse_args_in_yunohost_format_path_input_test_ask():
ask_text = "some question"
questions = [{
"name": "some_path",
"type": "path",
"ask": ask_text,
}]
questions = [{"name": "some_path", "type": "path", "ask": ask_text,}]
answers = {}
with patch.object(msignals, "prompt", return_value="some_value") as prompt:
@ -543,12 +449,9 @@ def test_parse_args_in_yunohost_format_path_input_test_ask():
def test_parse_args_in_yunohost_format_path_input_test_ask_with_default():
ask_text = "some question"
default_text = "some example"
questions = [{
"name": "some_path",
"type": "path",
"ask": ask_text,
"default": default_text,
}]
questions = [
{"name": "some_path", "type": "path", "ask": ask_text, "default": default_text,}
]
answers = {}
with patch.object(msignals, "prompt", return_value="some_value") as prompt:
@ -560,12 +463,9 @@ def test_parse_args_in_yunohost_format_path_input_test_ask_with_default():
def test_parse_args_in_yunohost_format_path_input_test_ask_with_example():
ask_text = "some question"
example_text = "some example"
questions = [{
"name": "some_path",
"type": "path",
"ask": ask_text,
"example": example_text,
}]
questions = [
{"name": "some_path", "type": "path", "ask": ask_text, "example": example_text,}
]
answers = {}
with patch.object(msignals, "prompt", return_value="some_value") as prompt:
@ -578,12 +478,9 @@ def test_parse_args_in_yunohost_format_path_input_test_ask_with_example():
def test_parse_args_in_yunohost_format_path_input_test_ask_with_help():
ask_text = "some question"
help_text = "some_help"
questions = [{
"name": "some_path",
"type": "path",
"ask": ask_text,
"help": help_text,
}]
questions = [
{"name": "some_path", "type": "path", "ask": ask_text, "help": help_text,}
]
answers = {}
with patch.object(msignals, "prompt", return_value="some_value") as prompt:
@ -593,53 +490,89 @@ def test_parse_args_in_yunohost_format_path_input_test_ask_with_help():
def test_parse_args_in_yunohost_format_boolean():
questions = [{
"name": "some_boolean",
"type": "boolean",
}]
questions = [{"name": "some_boolean", "type": "boolean",}]
answers = {"some_boolean": "y"}
expected_result = OrderedDict({"some_boolean": (1, "boolean")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_boolean_all_yes():
questions = [{
"name": "some_boolean",
"type": "boolean",
}]
questions = [{"name": "some_boolean", "type": "boolean",}]
expected_result = OrderedDict({"some_boolean": (1, "boolean")})
assert _parse_args_in_yunohost_format({"some_boolean": "y"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": "Y"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": "yes"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": "Yes"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": "YES"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": "1"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": 1}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": True}, questions) == expected_result
assert (
_parse_args_in_yunohost_format({"some_boolean": "y"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": "Y"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": "yes"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": "Yes"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": "YES"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": "1"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": 1}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": True}, questions)
== expected_result
)
def test_parse_args_in_yunohost_format_boolean_all_no():
questions = [{
"name": "some_boolean",
"type": "boolean",
}]
questions = [{"name": "some_boolean", "type": "boolean",}]
expected_result = OrderedDict({"some_boolean": (0, "boolean")})
assert _parse_args_in_yunohost_format({"some_boolean": "n"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": "N"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": "no"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": "No"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": "No"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": "0"}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": 0}, questions) == expected_result
assert _parse_args_in_yunohost_format({"some_boolean": False}, questions) == expected_result
assert (
_parse_args_in_yunohost_format({"some_boolean": "n"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": "N"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": "no"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": "No"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": "No"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": "0"}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": 0}, questions)
== expected_result
)
assert (
_parse_args_in_yunohost_format({"some_boolean": False}, questions)
== expected_result
)
# XXX apparently boolean are always False (0) by default, I'm not sure what to think about that
def test_parse_args_in_yunohost_format_boolean_no_input():
questions = [{
"name": "some_boolean",
"type": "boolean",
}]
questions = [{"name": "some_boolean", "type": "boolean",}]
answers = {}
expected_result = OrderedDict({"some_boolean": (0, "boolean")})
@ -647,10 +580,7 @@ def test_parse_args_in_yunohost_format_boolean_no_input():
def test_parse_args_in_yunohost_format_boolean_bad_input():
questions = [{
"name": "some_boolean",
"type": "boolean",
}]
questions = [{"name": "some_boolean", "type": "boolean",}]
answers = {"some_boolean": "stuff"}
with pytest.raises(YunohostError):
@ -658,11 +588,7 @@ def test_parse_args_in_yunohost_format_boolean_bad_input():
def test_parse_args_in_yunohost_format_boolean_input():
questions = [{
"name": "some_boolean",
"type": "boolean",
"ask": "some question",
}]
questions = [{"name": "some_boolean", "type": "boolean", "ask": "some question",}]
answers = {}
expected_result = OrderedDict({"some_boolean": (1, "boolean")})
@ -676,10 +602,7 @@ def test_parse_args_in_yunohost_format_boolean_input():
@pytest.mark.skip # we should work
def test_parse_args_in_yunohost_format_boolean_input_no_ask():
questions = [{
"name": "some_boolean",
"type": "boolean",
}]
questions = [{"name": "some_boolean", "type": "boolean",}]
answers = {}
expected_result = OrderedDict({"some_boolean": ("some_value", "boolean")})
@ -688,23 +611,21 @@ def test_parse_args_in_yunohost_format_boolean_input_no_ask():
def test_parse_args_in_yunohost_format_boolean_no_input_optional():
questions = [{
"name": "some_boolean",
"type": "boolean",
"optional": True,
}]
questions = [{"name": "some_boolean", "type": "boolean", "optional": True,}]
answers = {}
expected_result = OrderedDict({"some_boolean": (0, "boolean")}) # default to false
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_boolean_optional_with_input():
questions = [{
"name": "some_boolean",
"ask": "some question",
"type": "boolean",
"optional": True,
}]
questions = [
{
"name": "some_boolean",
"ask": "some question",
"type": "boolean",
"optional": True,
}
]
answers = {}
expected_result = OrderedDict({"some_boolean": (1, "boolean")})
@ -713,11 +634,7 @@ def test_parse_args_in_yunohost_format_boolean_optional_with_input():
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 = {}
expected_result = OrderedDict({"some_boolean": (0, "boolean")})
@ -726,12 +643,14 @@ def test_parse_args_in_yunohost_format_boolean_optional_with_input_without_ask()
def test_parse_args_in_yunohost_format_boolean_no_input_default():
questions = [{
"name": "some_boolean",
"ask": "some question",
"type": "boolean",
"default": 0,
}]
questions = [
{
"name": "some_boolean",
"ask": "some question",
"type": "boolean",
"default": 0,
}
]
answers = {}
expected_result = OrderedDict({"some_boolean": (0, "boolean")})
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
@ -739,12 +658,14 @@ def test_parse_args_in_yunohost_format_boolean_no_input_default():
@pytest.mark.skip # we should raise
def test_parse_args_in_yunohost_format_boolean_bad_default():
questions = [{
"name": "some_boolean",
"ask": "some question",
"type": "boolean",
"default": "bad default",
}]
questions = [
{
"name": "some_boolean",
"ask": "some question",
"type": "boolean",
"default": "bad default",
}
]
answers = {}
with pytest.raises(YunohostError):
_parse_args_in_yunohost_format(answers, questions)
@ -752,11 +673,7 @@ def test_parse_args_in_yunohost_format_boolean_bad_default():
def test_parse_args_in_yunohost_format_boolean_input_test_ask():
ask_text = "some question"
questions = [{
"name": "some_boolean",
"type": "boolean",
"ask": ask_text,
}]
questions = [{"name": "some_boolean", "type": "boolean", "ask": ask_text,}]
answers = {}
with patch.object(msignals, "prompt", return_value=0) as prompt:
@ -767,12 +684,14 @@ def test_parse_args_in_yunohost_format_boolean_input_test_ask():
def test_parse_args_in_yunohost_format_boolean_input_test_ask_with_default():
ask_text = "some question"
default_text = 1
questions = [{
"name": "some_boolean",
"type": "boolean",
"ask": ask_text,
"default": default_text,
}]
questions = [
{
"name": "some_boolean",
"type": "boolean",
"ask": ask_text,
"default": default_text,
}
]
answers = {}
with patch.object(msignals, "prompt", return_value=1) as prompt: