mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
We don't need app-type argument for manifest questions
This commit is contained in:
parent
ba884d5b6d
commit
3a23f9715f
2 changed files with 0 additions and 214 deletions
|
@ -2631,22 +2631,6 @@ class UserArgumentParser(YunoHostArgumentFormatParser):
|
||||||
error=m18n.n('user_unknown', user=question.value))
|
error=m18n.n('user_unknown', user=question.value))
|
||||||
|
|
||||||
|
|
||||||
class AppArgumentParser(YunoHostArgumentFormatParser):
|
|
||||||
argument_type = "app"
|
|
||||||
|
|
||||||
def parse_question(self, question, user_answers):
|
|
||||||
from yunohost.app import app_list
|
|
||||||
|
|
||||||
question = super(AppArgumentParser, self).parse_question(question, user_answers)
|
|
||||||
question.choices = [x["id"] for x in app_list()["apps"]]
|
|
||||||
|
|
||||||
return question
|
|
||||||
|
|
||||||
def _raise_invalid_answer(self, question):
|
|
||||||
raise YunohostError('app_argument_invalid', name=question.name,
|
|
||||||
error=m18n.n('app_unknown'))
|
|
||||||
|
|
||||||
|
|
||||||
class DisplayTextArgumentParser(YunoHostArgumentFormatParser):
|
class DisplayTextArgumentParser(YunoHostArgumentFormatParser):
|
||||||
argument_type = "display_text"
|
argument_type = "display_text"
|
||||||
|
|
||||||
|
@ -2661,7 +2645,6 @@ ARGUMENTS_TYPE_PARSERS = {
|
||||||
"boolean": BooleanArgumentParser,
|
"boolean": BooleanArgumentParser,
|
||||||
"domain": DomainArgumentParser,
|
"domain": DomainArgumentParser,
|
||||||
"user": UserArgumentParser,
|
"user": UserArgumentParser,
|
||||||
"app": AppArgumentParser,
|
|
||||||
"display_text": DisplayTextArgumentParser,
|
"display_text": DisplayTextArgumentParser,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1021,203 +1021,6 @@ def test_parse_args_in_yunohost_format_user_two_users_default_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_app_empty():
|
|
||||||
apps = [
|
|
||||||
{
|
|
||||||
"id": "my_webapp",
|
|
||||||
"version": "1.0~ynh2",
|
|
||||||
"description": "Custom Web app with SFTP access",
|
|
||||||
"name": "Custom Webapp",
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
questions = [{"name": "some_app", "type": "app", }]
|
|
||||||
answers = {}
|
|
||||||
|
|
||||||
with patch.object(app, "app_list", return_value={"apps": apps}):
|
|
||||||
with pytest.raises(YunohostError):
|
|
||||||
_parse_args_in_yunohost_format(answers, questions)
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_args_in_yunohost_format_app_no_apps():
|
|
||||||
apps = []
|
|
||||||
questions = [{"name": "some_app", "type": "app", }]
|
|
||||||
answers = {}
|
|
||||||
|
|
||||||
with patch.object(app, "app_list", return_value={"apps": apps}):
|
|
||||||
with pytest.raises(YunohostError):
|
|
||||||
_parse_args_in_yunohost_format(answers, questions)
|
|
||||||
|
|
||||||
|
|
||||||
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) == expected_result
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_args_in_yunohost_format_app():
|
|
||||||
app_name = "my_webapp"
|
|
||||||
apps = [
|
|
||||||
{
|
|
||||||
"id": app_name,
|
|
||||||
"version": "1.0~ynh2",
|
|
||||||
"description": "Custom Web app with SFTP access",
|
|
||||||
"name": "Custom Webapp",
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
questions = [{"name": "some_app", "type": "app", }]
|
|
||||||
answers = {"some_app": app_name}
|
|
||||||
|
|
||||||
expected_result = OrderedDict({"some_app": (app_name, "app")})
|
|
||||||
|
|
||||||
with patch.object(app, "app_list", return_value={"apps": apps}), patch.object(
|
|
||||||
app,
|
|
||||||
"_is_installed",
|
|
||||||
new_callable=lambda: lambda app_id: app_id in {x["id"] for x in apps},
|
|
||||||
):
|
|
||||||
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_args_in_yunohost_format_app_two_apps():
|
|
||||||
app_name = "my_webapp"
|
|
||||||
other_app = "some_other_app"
|
|
||||||
apps = [
|
|
||||||
{
|
|
||||||
"id": app_name,
|
|
||||||
"version": "1.0~ynh2",
|
|
||||||
"description": "Custom Web app with SFTP access",
|
|
||||||
"name": "Custom Webapp",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": other_app,
|
|
||||||
"version": "1.0",
|
|
||||||
"description": "blabla",
|
|
||||||
"name": "stuff",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
questions = [{"name": "some_app", "type": "app", }]
|
|
||||||
answers = {"some_app": other_app}
|
|
||||||
expected_result = OrderedDict({"some_app": (other_app, "app")})
|
|
||||||
|
|
||||||
with patch.object(app, "app_list", return_value={"apps": apps}), patch.object(
|
|
||||||
app,
|
|
||||||
"_is_installed",
|
|
||||||
new_callable=lambda: lambda app_id: app_id in {x["id"] for x in apps},
|
|
||||||
):
|
|
||||||
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
|
|
||||||
|
|
||||||
answers = {"some_app": app_name}
|
|
||||||
expected_result = OrderedDict({"some_app": (app_name, "app")})
|
|
||||||
|
|
||||||
with patch.object(app, "app_list", return_value={"apps": apps}), patch.object(
|
|
||||||
app,
|
|
||||||
"_is_installed",
|
|
||||||
new_callable=lambda: lambda app_id: app_id in {x["id"] for x in apps},
|
|
||||||
):
|
|
||||||
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_args_in_yunohost_format_app_two_apps_wrong_answer():
|
|
||||||
app_name = "my_webapp"
|
|
||||||
other_app = "some_other_app"
|
|
||||||
apps = [
|
|
||||||
{
|
|
||||||
"id": app_name,
|
|
||||||
"version": "1.0~ynh2",
|
|
||||||
"description": "Custom Web app with SFTP access",
|
|
||||||
"name": "Custom Webapp",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": other_app,
|
|
||||||
"version": "1.0",
|
|
||||||
"description": "blabla",
|
|
||||||
"name": "stuff",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
questions = [{"name": "some_app", "type": "app", }]
|
|
||||||
answers = {"some_app": "doesnt_exist"}
|
|
||||||
|
|
||||||
with pytest.raises(YunohostError):
|
|
||||||
with patch.object(app, "app_list", return_value={"apps": apps}), patch.object(
|
|
||||||
app,
|
|
||||||
"_is_installed",
|
|
||||||
new_callable=lambda: lambda app_id: app_id in {x["id"] for x in apps},
|
|
||||||
):
|
|
||||||
_parse_args_in_yunohost_format(answers, questions)
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_args_in_yunohost_format_app_two_apps_no_default():
|
|
||||||
app_name = "my_app_name.com"
|
|
||||||
other_app = "some_other_app"
|
|
||||||
apps = [
|
|
||||||
{
|
|
||||||
"id": app_name,
|
|
||||||
"version": "1.0~ynh2",
|
|
||||||
"description": "Custom Web app with SFTP access",
|
|
||||||
"name": "Custom Webapp",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": other_app,
|
|
||||||
"version": "1.0",
|
|
||||||
"description": "blabla",
|
|
||||||
"name": "stuff",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
questions = [{"name": "some_app", "type": "app", "ask": "choose a app"}]
|
|
||||||
answers = {}
|
|
||||||
|
|
||||||
with patch.object(app, "app_list", return_value={"apps": apps}), patch.object(
|
|
||||||
app,
|
|
||||||
"_is_installed",
|
|
||||||
new_callable=lambda: lambda app_id: app_id in {x["id"] for x in apps},
|
|
||||||
):
|
|
||||||
with pytest.raises(YunohostError):
|
|
||||||
_parse_args_in_yunohost_format(answers, questions)
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_args_in_yunohost_format_app_two_apps_default_input():
|
|
||||||
app_name = "my_app_name.com"
|
|
||||||
other_app = "some_other_app"
|
|
||||||
apps = [
|
|
||||||
{
|
|
||||||
"id": app_name,
|
|
||||||
"version": "1.0~ynh2",
|
|
||||||
"description": "Custom Web app with SFTP access",
|
|
||||||
"name": "Custom Webapp",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": other_app,
|
|
||||||
"version": "1.0",
|
|
||||||
"description": "blabla",
|
|
||||||
"name": "stuff",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
questions = [{"name": "some_app", "type": "app", "ask": "choose a app"}]
|
|
||||||
answers = {}
|
|
||||||
|
|
||||||
with patch.object(app, "app_list", return_value={"apps": apps}), patch.object(
|
|
||||||
app,
|
|
||||||
"_is_installed",
|
|
||||||
new_callable=lambda: lambda app_id: app_id in {x["id"] for x in apps},
|
|
||||||
):
|
|
||||||
expected_result = OrderedDict({"some_app": (app_name, "app")})
|
|
||||||
with patch.object(msignals, "prompt", return_value=app_name):
|
|
||||||
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
|
|
||||||
|
|
||||||
expected_result = OrderedDict({"some_app": (other_app, "app")})
|
|
||||||
with patch.object(msignals, "prompt", return_value=other_app):
|
|
||||||
assert _parse_args_in_yunohost_format(answers, questions) == expected_result
|
|
||||||
|
|
||||||
|
|
||||||
def test_parse_args_in_yunohost_format_display_text():
|
def test_parse_args_in_yunohost_format_display_text():
|
||||||
questions = [{"name": "some_app", "type": "display_text", "ask": "foobar"}]
|
questions = [{"name": "some_app", "type": "display_text", "ask": "foobar"}]
|
||||||
answers = {}
|
answers = {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue