Merge pull request #1135 from YunoHost/fix-default-in-arg-parse

fix default arg parse for password
This commit is contained in:
Alexandre Aubin 2021-01-14 19:46:54 +01:00 committed by GitHub
commit 739d831cf9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -2424,6 +2424,10 @@ class YunoHostArgumentFormatParser(object):
if parsed_question.ask is None: if parsed_question.ask is None:
parsed_question.ask = "Enter value for '%s':" % parsed_question.name parsed_question.ask = "Enter value for '%s':" % parsed_question.name
# Empty value is parsed as empty string
if parsed_question.default == "":
parsed_question.default = None
return parsed_question return parsed_question
def parse(self, question, user_answers): def parse(self, question, user_answers):

View file

@ -260,6 +260,10 @@ def test_parse_args_in_yunohost_format_password_no_input_optional():
assert _parse_args_in_yunohost_format(answers, questions) == expected_result assert _parse_args_in_yunohost_format(answers, questions) == expected_result
questions = [{"name": "some_password", "type": "password", "optional": True, "default": ""}]
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
def test_parse_args_in_yunohost_format_password_optional_with_input(): def test_parse_args_in_yunohost_format_password_optional_with_input():
questions = [ questions = [