diff options
Diffstat (limited to 'conftest.py')
-rw-r--r-- | conftest.py | 81 |
1 files changed, 45 insertions, 36 deletions
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<tr bgcolor = \"" + bgcolor + "\">\n" - html_data += "\t\t<th><font color = \"" + color + "\"> test suite </font></th>\n" - html_data += "\t\t<th><font color = \"" + color + "\"> status </font></th>\n" - html_data += "\t\t<th><font color = \"" + color + "\"> total </font></th>\n" - html_data += "\t\t<th><font color = \"" + color + "\"> pass </font></th>\n" - html_data += "\t\t<th><font color = \"" + color + "\"> xpass </font></th>\n" - html_data += "\t\t<th><font color = \"" + color + "\"> fail </font></th>\n" - html_data += "\t\t<th><font color = \"" + color + "\"> xfail </font></th>\n" - html_data += "\t\t<th><font color = \"" + color + "\"> skip </font></th>\n" - html_data += "\t</tr>\n" - #init all rows - bgcolor = conf.BGCOLOR_DARK for key in summary_data: if(key != "summary"): - html_data += "\t<tr bgcolor = \"" + bgcolor + "\">\n" - html_data += "\t\t<th>" + key + "</th>\n" - html_data += "\t\t<th>" + summary_data[key]["test_status"] + "</th>\n" - html_data += "\t\t<th>" + str(summary_data[key]["total"]) + "</th>\n" - html_data += "\t\t<th>" + str(summary_data[key]["passed"]) + "</th>\n" - html_data += "\t\t<th>" + str(summary_data[key]["xpassed"]) + "</th>\n" - html_data += "\t\t<th>" + str(summary_data[key]["failed"]) + "</th>\n" - html_data += "\t\t<th>" + str(summary_data[key]["xfailed"]) + "</th>\n" - html_data += "\t\t<th>" + str(summary_data[key]["skipped"]) + "</th>\n" - html_data += "\t</tr>\n" - - if (bgcolor == conf.BGCOLOR_DARK): - bgcolor = conf.BGCOLOR_LIGHT - else: - bgcolor = conf.BGCOLOR_DARK + html_data += "\t\t\t<tbody class=\"" + html_data += summary_data[key]["test_status"] + "\">\n" + html_data += "\t\t\t\t<tr>\n" + html_data += "\t\t\t\t<td class=\"col-result\">" + html_data += str.capitalize(summary_data[key]["test_status"]) + html_data += "</td>\n" + html_data += "\t\t\t\t<td>" + key + "</td>\n" + html_data += "\t\t\t\t<td>" + str(summary_data[key]["total"]) + html_data += "</td>\n" + html_data += "\t\t\t\t<td>" + str(summary_data[key]["passed"]) + html_data += "</td>\n" + html_data += "\t\t\t\t<td>" + str(summary_data[key]["skipped"]) + html_data += "</td>\n" + html_data += "\t\t\t\t<td>" + str(summary_data[key]["failed"]) + html_data += "</td>\n" + html_data += "\t\t\t\t<td>" + str(summary_data[key]["xfailed"]) + html_data += "</td>\n" + html_data += "\t\t\t\t<td>" + str(summary_data[key]["xpassed"]) + html_data += "</td>\n" + html_data += "\t\t\t\t</tr>\n" + html_data += "\t\t\t</tbody>\n" + summary_data["test_suite_table_html"] = html_data + + #Create summry status in html + summry_status_html = "" + summry_status_html += "\t\t<p>test suite status : <span class=\"" + summry_status_html += summary_data["summary"]["status"] + "\">" + summry_status_html += str.capitalize(summary_data["summary"]["status"]) + summry_status_html += "</span></p>" + summary_data["summry_status_html"] = summry_status_html + return summary_data |