[fix] allow optional app argument

This commit is contained in:
Laurent Peuch 2020-06-01 12:37:10 +02:00
parent dc6a12f14b
commit ecb52b4f11
2 changed files with 3 additions and 3 deletions

View file

@ -2429,7 +2429,7 @@ class YunoHostArgumentFormatParser(object):
if not question.optional and question.default is None:
raise YunohostError('app_argument_required', name=question.name)
else:
question.value = self.default_value if question.default is None else question.default
question.value = getattr(self, "default_value", None) if question.default is None else question.default
# we have an answer, do some post checks
if question.value is not None:

View file

@ -1011,14 +1011,14 @@ def test_parse_args_in_yunohost_format_app_no_apps():
_parse_args_in_yunohost_format(answers, questions)
@pytest.mark.skip # XXX should work
def test_parse_args_in_yunohost_format_app_no_apps_optional():
apps = []
questions = [{"name": "some_app", "type": "app", "optional": True}]
answers = {}
expected_result = OrderedDict({"some_app": (None, "app")})
with patch.object(app, "app_list", return_value={"apps": apps}):
assert _parse_args_in_yunohost_format(answers, questions) == []
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_app():