mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Fix tests
This commit is contained in:
parent
92f9e15e2f
commit
8ea160b9fe
2 changed files with 32 additions and 13 deletions
|
@ -207,6 +207,8 @@ def test_question_string_input_test_ask():
|
||||||
confirm=False,
|
confirm=False,
|
||||||
prefill="",
|
prefill="",
|
||||||
is_multiline=False,
|
is_multiline=False,
|
||||||
|
autocomplete=[],
|
||||||
|
help=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,6 +234,8 @@ def test_question_string_input_test_ask_with_default():
|
||||||
confirm=False,
|
confirm=False,
|
||||||
prefill=default_text,
|
prefill=default_text,
|
||||||
is_multiline=False,
|
is_multiline=False,
|
||||||
|
autocomplete=[],
|
||||||
|
help=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -526,6 +530,8 @@ def test_question_password_input_test_ask():
|
||||||
confirm=False,
|
confirm=False,
|
||||||
prefill="",
|
prefill="",
|
||||||
is_multiline=False,
|
is_multiline=False,
|
||||||
|
autocomplete=[],
|
||||||
|
help=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -787,6 +793,8 @@ def test_question_path_input_test_ask():
|
||||||
confirm=False,
|
confirm=False,
|
||||||
prefill="",
|
prefill="",
|
||||||
is_multiline=False,
|
is_multiline=False,
|
||||||
|
autocomplete=[],
|
||||||
|
help=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -813,6 +821,8 @@ def test_question_path_input_test_ask_with_default():
|
||||||
confirm=False,
|
confirm=False,
|
||||||
prefill=default_text,
|
prefill=default_text,
|
||||||
is_multiline=False,
|
is_multiline=False,
|
||||||
|
autocomplete=[],
|
||||||
|
help=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1162,6 +1172,8 @@ def test_question_boolean_input_test_ask():
|
||||||
confirm=False,
|
confirm=False,
|
||||||
prefill="no",
|
prefill="no",
|
||||||
is_multiline=False,
|
is_multiline=False,
|
||||||
|
autocomplete=[],
|
||||||
|
help=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1188,6 +1200,8 @@ def test_question_boolean_input_test_ask_with_default():
|
||||||
confirm=False,
|
confirm=False,
|
||||||
prefill="yes",
|
prefill="yes",
|
||||||
is_multiline=False,
|
is_multiline=False,
|
||||||
|
autocomplete=[],
|
||||||
|
help=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1735,6 +1749,8 @@ def test_question_number_input_test_ask():
|
||||||
confirm=False,
|
confirm=False,
|
||||||
prefill="",
|
prefill="",
|
||||||
is_multiline=False,
|
is_multiline=False,
|
||||||
|
autocomplete=[],
|
||||||
|
help=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1761,6 +1777,8 @@ def test_question_number_input_test_ask_with_default():
|
||||||
confirm=False,
|
confirm=False,
|
||||||
prefill=str(default_value),
|
prefill=str(default_value),
|
||||||
is_multiline=False,
|
is_multiline=False,
|
||||||
|
autocomplete=[],
|
||||||
|
help=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -573,13 +573,16 @@ class Question(object):
|
||||||
|
|
||||||
# Prevent displaying a shitload of choices
|
# Prevent displaying a shitload of choices
|
||||||
# (e.g. 100+ available users when choosing an app admin...)
|
# (e.g. 100+ available users when choosing an app admin...)
|
||||||
choices_to_display = self.choices[:20]
|
choices = list(self.choices.values()) if isinstance(self.choices, dict) else self.choices
|
||||||
remaining_choices = len(self.choices[20:])
|
choices_to_display = choices[:20]
|
||||||
|
remaining_choices = len(choices[20:])
|
||||||
|
|
||||||
if remaining_choices > 0:
|
if remaining_choices > 0:
|
||||||
choices_to_display += [m18n.n("other_available_options", n=remaining_choices)]
|
choices_to_display += [m18n.n("other_available_options", n=remaining_choices)]
|
||||||
|
|
||||||
text_for_user_input_in_cli += " [{0}]".format(" | ".join(choices_to_display))
|
choices_to_display = " | ".join(choices_to_display)
|
||||||
|
|
||||||
|
text_for_user_input_in_cli += f" [{choices_to_display}]"
|
||||||
|
|
||||||
return text_for_user_input_in_cli
|
return text_for_user_input_in_cli
|
||||||
|
|
||||||
|
@ -752,7 +755,7 @@ class BooleanQuestion(Question):
|
||||||
|
|
||||||
raise YunohostValidationError(
|
raise YunohostValidationError(
|
||||||
"app_argument_choice_invalid",
|
"app_argument_choice_invalid",
|
||||||
name=option.get("name", ""),
|
name=getattr(option, "name", None) or option.get("name"),
|
||||||
value=value,
|
value=value,
|
||||||
# FIXME : this doesn't match yes_answers / no_answers...
|
# FIXME : this doesn't match yes_answers / no_answers...
|
||||||
choices="yes, no, y, n, 1, 0",
|
choices="yes, no, y, n, 1, 0",
|
||||||
|
@ -788,7 +791,7 @@ class BooleanQuestion(Question):
|
||||||
return None
|
return None
|
||||||
raise YunohostValidationError(
|
raise YunohostValidationError(
|
||||||
"app_argument_choice_invalid",
|
"app_argument_choice_invalid",
|
||||||
name=option.get("name", ""),
|
name=getattr(option, "name", None) or option.get("name"),
|
||||||
value=value,
|
value=value,
|
||||||
choices="yes, no, y, n, 1, 0",
|
choices="yes, no, y, n, 1, 0",
|
||||||
)
|
)
|
||||||
|
@ -808,10 +811,7 @@ class BooleanQuestion(Question):
|
||||||
return text_for_user_input_in_cli
|
return text_for_user_input_in_cli
|
||||||
|
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
try:
|
return getattr(self, key, default)
|
||||||
return getattr(self, key)
|
|
||||||
except AttributeError:
|
|
||||||
return default
|
|
||||||
|
|
||||||
|
|
||||||
class DomainQuestion(Question):
|
class DomainQuestion(Question):
|
||||||
|
@ -843,7 +843,7 @@ class UserQuestion(Question):
|
||||||
from yunohost.domain import _get_maindomain
|
from yunohost.domain import _get_maindomain
|
||||||
|
|
||||||
super().__init__(question, user_answers)
|
super().__init__(question, user_answers)
|
||||||
self.choices = user_list()["users"]
|
self.choices = list(user_list()["users"].keys())
|
||||||
|
|
||||||
if not self.choices:
|
if not self.choices:
|
||||||
raise YunohostValidationError(
|
raise YunohostValidationError(
|
||||||
|
@ -854,7 +854,7 @@ class UserQuestion(Question):
|
||||||
|
|
||||||
if self.default is None:
|
if self.default is None:
|
||||||
root_mail = "root@%s" % _get_maindomain()
|
root_mail = "root@%s" % _get_maindomain()
|
||||||
for user in self.choices.keys():
|
for user in self.choices:
|
||||||
if root_mail in user_info(user).get("mail-aliases", []):
|
if root_mail in user_info(user).get("mail-aliases", []):
|
||||||
self.default = user
|
self.default = user
|
||||||
break
|
break
|
||||||
|
@ -891,9 +891,10 @@ class NumberQuestion(Question):
|
||||||
if value in [None, ""]:
|
if value in [None, ""]:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
# FIXME: option.name may not exist if option={}...
|
|
||||||
raise YunohostValidationError(
|
raise YunohostValidationError(
|
||||||
"app_argument_invalid", name=option.get("name", ""), error=m18n.n("invalid_number")
|
"app_argument_invalid",
|
||||||
|
name=getattr(option, "name", None) or option.get("name"),
|
||||||
|
error=m18n.n("invalid_number")
|
||||||
)
|
)
|
||||||
|
|
||||||
def _prevalidate(self):
|
def _prevalidate(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue