Skip to content

Commit

Permalink
Refs #79. Added form for TeraTestType
Browse files Browse the repository at this point in the history
  • Loading branch information
SBriere committed Apr 5, 2022
1 parent 6d543e1 commit 5124b07
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get(self):
test_types = [TeraTestType.get_test_type_by_id(args['id_test_type'])]
elif args['test_type_key']:
test_type = TeraTestType.get_test_type_by_key(args['test_type_key'])
if test_type.id_test_type in service_access.get_accessible_tests_types_ids():
if test_type and test_type.id_test_type in service_access.get_accessible_tests_types_ids():
test_types = [test_type]
else:
test_types = service_access.get_accessible_tests_types()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from opentera.forms.TeraServiceConfigForm import TeraServiceConfigForm
from opentera.forms.TeraVersionsForm import TeraVersionsForm
from opentera.forms.TeraSessionTypeConfigForm import TeraSessionTypeConfigForm
from opentera.forms.TeraTestTypeForm import TeraTestTypeForm

get_parser = api.parser()
get_parser.add_argument(name='type', type=str, help='Data type of the required form. Currently, the '
Expand All @@ -38,6 +39,7 @@
'session_type\n'
'session_type_config\n'
'site\n'
'test_type\n'
'user\n'
'user_group\n'
'versions\n'
Expand Down Expand Up @@ -144,6 +146,9 @@ def get(self):
if args['type'] == 'versions':
return TeraVersionsForm.get_versions_form(user_access=user_access)

if args['type'] == 'test_type':
return TeraTestTypeForm.get_test_type_form(user_access=user_access)

self.module.logger.log_error(self.module.module_name,
UserQueryForms.__name__,
'get', 500, 'Unknown form type: ' + args['type'])
Expand Down
35 changes: 35 additions & 0 deletions teraserver/python/opentera/forms/TeraTestTypeForm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from opentera.forms.TeraForm import *
from flask_babel import gettext
from modules.DatabaseModule.DBManagerTeraUserAccess import DBManagerTeraUserAccess


class TeraTestTypeForm:

@staticmethod
def get_test_type_form(user_access: DBManagerTeraUserAccess):
form = TeraForm("session_type")

# Building lists
services = user_access.get_accessible_services()
services_list = []
for service in services:
services_list.append(TeraFormValue(value_id=service.id_service, value=service.service_name))

# Sections
section = TeraFormSection("informations", gettext("Information"))
form.add_section(section)

# Items
section.add_item(TeraFormItem("id_test_type", gettext("Test Type ID"), "hidden", True))
section.add_item(TeraFormItem("id_service", gettext("Service"), "array", item_required=False,
item_values=services_list)
)
section.add_item(TeraFormItem("test_type_uuid", gettext("UUID"), "hidden", True))
section.add_item(TeraFormItem("test_type_name", gettext("Name"), "text", True))
section.add_item(TeraFormItem("test_type_description", gettext("Description"), "longtext", False))
section.add_item(TeraFormItem("test_type_key", gettext("Unique Key"), "text", False))
section.add_item(TeraFormItem("test_type_has_json_format", gettext("Expose JSON structure"), "boolean", False))
section.add_item(TeraFormItem("test_type_has_web_format", gettext("Expose Web interface"), "boolean", False))
section.add_item(TeraFormItem("test_type_has_web_editor", gettext("Expose Web editor"), "boolean", False))

return form.to_dict()

0 comments on commit 5124b07

Please sign in to comment.