From 2f9db91f9e63e7b746770b17c2c9204ff663a7de Mon Sep 17 00:00:00 2001 From: duerpei Date: Sat, 22 Oct 2022 16:55:45 +0800 Subject: agl-test-framework: optimize the generated html report Optimize the generated html report, make its format more beautiful and readable. Bug-AGL: SPEC-4345 Signed-off-by: duerpei Change-Id: I0b779e0998ded00b348e23f2c1ac5b8acf5b8fd8 --- conftest.py | 81 ++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 45 insertions(+), 36 deletions(-) (limited to 'conftest.py') diff --git a/conftest.py b/conftest.py index 0c42f66..fb89772 100644 --- a/conftest.py +++ b/conftest.py @@ -41,9 +41,17 @@ def setup_compress_function(): date = subprocess.getoutput('date +%Y%m%d') zip_name = "agl-test-log-" + version + '-' + machine_name + '-' + date - #Creat summary report in html - summary_html_data = format_test_suite_table(summary_data) + #Get summary_html_data + summary_html_data = format_html_data(summary_data) summary_html_data["log_zip_name"] = zip_name + + #Get timestamp + date_F = subprocess.getoutput("date +%F") + summary_html_data["date_F"] = date_F + date_T = subprocess.getoutput("date +%T") + summary_html_data["date_T"] = date_T + + #Creat summary report in html env = Environment(loader=FileSystemLoader(conf.get_tpl_dir())) template = env.get_template("all_test_suites_tpl.html") html_path = conf.TMP_LOGS_DIR + "test-report/summary-report.html" @@ -115,49 +123,50 @@ def get_summary_data(report_files): status = "" if (summary_data["summary"]["summary_total"] == summary_data["summary"]["summary_skipped"]): - status = "skip" + status = "skipped" elif (summary_data["summary"]["summary_failed"] == 0): - status = "pass" + status = "passed" else: - status = "fail" + status = "failed" summary_data["summary"]["status"] = status return summary_data -def format_test_suite_table(summary_data): +def format_html_data(summary_data): html_data = "" - #init table title - bgcolor = conf.BGCOLOR_TABLE_TITLE - color = conf.COLOR_TABLE_TITLE - html_data += "\t\n" - html_data += "\t\t test suite \n" - html_data += "\t\t status \n" - html_data += "\t\t total \n" - html_data += "\t\t pass \n" - html_data += "\t\t xpass \n" - html_data += "\t\t fail \n" - html_data += "\t\t xfail \n" - html_data += "\t\t skip \n" - html_data += "\t\n" - #init all rows - bgcolor = conf.BGCOLOR_DARK for key in summary_data: if(key != "summary"): - html_data += "\t\n" - html_data += "\t\t" + key + "\n" - html_data += "\t\t" + summary_data[key]["test_status"] + "\n" - html_data += "\t\t" + str(summary_data[key]["total"]) + "\n" - html_data += "\t\t" + str(summary_data[key]["passed"]) + "\n" - html_data += "\t\t" + str(summary_data[key]["xpassed"]) + "\n" - html_data += "\t\t" + str(summary_data[key]["failed"]) + "\n" - html_data += "\t\t" + str(summary_data[key]["xfailed"]) + "\n" - html_data += "\t\t" + str(summary_data[key]["skipped"]) + "\n" - html_data += "\t\n" - - if (bgcolor == conf.BGCOLOR_DARK): - bgcolor = conf.BGCOLOR_LIGHT - else: - bgcolor = conf.BGCOLOR_DARK + html_data += "\t\t\t\n" + html_data += "\t\t\t\t\n" + html_data += "\t\t\t\t" + html_data += str.capitalize(summary_data[key]["test_status"]) + html_data += "\n" + html_data += "\t\t\t\t" + key + "\n" + html_data += "\t\t\t\t" + str(summary_data[key]["total"]) + html_data += "\n" + html_data += "\t\t\t\t" + str(summary_data[key]["passed"]) + html_data += "\n" + html_data += "\t\t\t\t" + str(summary_data[key]["skipped"]) + html_data += "\n" + html_data += "\t\t\t\t" + str(summary_data[key]["failed"]) + html_data += "\n" + html_data += "\t\t\t\t" + str(summary_data[key]["xfailed"]) + html_data += "\n" + html_data += "\t\t\t\t" + str(summary_data[key]["xpassed"]) + html_data += "\n" + html_data += "\t\t\t\t\n" + html_data += "\t\t\t\n" + summary_data["test_suite_table_html"] = html_data + + #Create summry status in html + summry_status_html = "" + summry_status_html += "\t\t

test suite status : " + summry_status_html += str.capitalize(summary_data["summary"]["status"]) + summry_status_html += "

" + summary_data["summry_status_html"] = summry_status_html + return summary_data -- cgit