blob: 4ec5fc93001a4c54f7e9cb666de56da183b23b58 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# -*- coding: UTF-8 -*-
import os
from support.report import *
from datetime import datetime
class ReportUpdate:
def write_result(self, parameter, result, exception_result):
file_path = parameter["root_path"] + "/report/{}_automation_test_report.csv".format(parameter["module_name"])
if os.path.exists(file_path) and os.path.isfile(file_path):
if isinstance(result, str) and result is not None and result != "" and len(result) != 0 or isinstance(result, dict) and (len(result["ui_result"]) != 0 or len(result["api_result"]) != 0):
report_data = []
report_data.append(parameter["test_case_name"])
result_flag = "Fail"
report_data.append(result_flag)
temp_result = "UI automation result: " + result["ui_result"] + " API automation result: " + result["api_result"]
report_data.append(temp_result)
elif exception_result is not None and exception_result != "" and len(exception_result) != 0:
report_data = []
report_data.append("test_case_name")
result_flag = "Fail"
report_data.append(result_flag)
report_data.append(exception_result)
elif (isinstance(result, str) and result == "" and len(result) == 0 or isinstance(result, dict) and len(result["ui_result"]) == 0 and len(result["api_result"]) == 0) and exception_result == "" and len(exception_result) == 0:
report_data = []
report_data.append("test_case_name")
result_flag = "Pass"
report_data.append(result_flag)
report_data.append("")
new_report = GenerateReport()
new_report.insert_data(parameter, report_data)
if __name__ == "__main__":
print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "test")
|