feat(GODT-2788): Add preview to bug report validation.

This commit is contained in:
Romain Le Jeune
2023-08-09 11:39:08 +00:00
parent 9d0d3708af
commit e8ce8942be
3 changed files with 41 additions and 0 deletions

View File

@ -118,6 +118,15 @@ lint:
tags: tags:
- medium - medium
bug-report-preview:
stage: test
extends:
- .rules-branch-and-MR-manual
script:
- make lint-bug-report-preview
tags:
- medium
.script-test: .script-test:
stage: test stage: test
extends: extends:

View File

@ -310,6 +310,9 @@ lint-golang:
lint-bug-report: lint-bug-report:
python3 utils/validate_bug_report_file.py --file "internal/frontend/bridge-gui/bridge-gui/qml/Resources/bug_report_flow.json" python3 utils/validate_bug_report_file.py --file "internal/frontend/bridge-gui/bridge-gui/qml/Resources/bug_report_flow.json"
lint-bug-report-preview:
python3 utils/validate_bug_report_file.py --file "internal/frontend/bridge-gui/bridge-gui/qml/Resources/bug_report_flow.json" --preview
gobinsec: gobinsec-cache.yml build gobinsec: gobinsec-cache.yml build
gobinsec -wait -cache -config utils/gobinsec_conf.yml ${EXE_TARGET} ${DEPLOY_DIR}/${TARGET_OS}/${LAUNCHER_EXE} gobinsec -wait -cache -config utils/gobinsec_conf.yml ${EXE_TARGET} ${DEPLOY_DIR}/${TARGET_OS}/${LAUNCHER_EXE}

View File

@ -181,10 +181,37 @@ class BugReportJson:
unique_list.append(question) unique_list.append(question)
return True return True
def preview(self):
for category in self.categories:
self.preview_category(category)
def preview_category(self, category):
print(" > %s" % category["name"])
if "hint" in category and category["hint"]:
print("(%s)" % category["hint"])
for question in category["questions"]:
self.preview_question(self.questions[question])
print("\n\r")
return 0
def preview_question(self, question):
# ["id", "text", "tips", "type", "mandatory", "maxChar", "answerList"]
mandatory = ("mandatory" in question and question["mandatory"])
mandatory_sym = " *"
if not mandatory:
mandatory_sym = ""
print("\t - %s%s" % (question["text"], mandatory_sym))
if "tips" in question and question["tips"]:
print("\t (%s)" % question["tips"])
if "answerList" in question:
for answer in question["answerList"]:
print("\t\t - %s" % answer)
return 0
def parse_args(): def parse_args():
parser = argparse.ArgumentParser(description='Validate Bug Report File.') parser = argparse.ArgumentParser(description='Validate Bug Report File.')
parser.add_argument('--file', required=True, help='JSON file to validate.') parser.add_argument('--file', required=True, help='JSON file to validate.')
parser.add_argument('--preview', action='store_true', help='Output a preview of the parsed file.')
return parser.parse_args() return parser.parse_args()
@ -196,6 +223,8 @@ def main():
print("Validation FAILED for %s. Error: %s" %(report.filepath, report.error)) print("Validation FAILED for %s. Error: %s" %(report.filepath, report.error))
exit(1) exit(1)
print("Validation SUCCEED for %s." % report.filepath) print("Validation SUCCEED for %s." % report.filepath)
if args.preview:
report.preview()
exit(0) exit(0)