コード例 #1
0
 def execute_all_test_for_cron_and_single_test(self):
     test_results = []
     for test_case in self.test_case_list:
         backup_test_start = time.time()
         test_start_datetime = datetime.datetime.utcnow()
         test_result = self.execute_single_test(test_case)
         backup_test_end = time.time()
         backup_test_spending_time = round(backup_test_end - backup_test_start, 3)
         if 'lastManualTestResult' in test_case:
             test_case.pop('lastManualTestResult')
         domain = test_case["domain"] if 'domain' in test_case and isinstance(test_case["domain"], str) and \
                                         not test_case["domain"].strip() == '' else self.domain
         if 'requestProtocol' in test_case and 'route' in test_case:
             url = '%s://%s%s' % (test_case['requestProtocol'].lower(), domain, test_case['route'])
             test_case["url"] = url
         test_case['curl'] = common.generate_curl(method=test_case["requestMethod"],
                                                  url=test_case["url"],
                                                  headers=test_case["headers"],
                                                  data=test_case['presendParams'])
         test_result["spendingTimeInSec"] = test_case.pop('spendingTimeInSec')\
             if 'spendingTimeInSec' in test_case else backup_test_spending_time
         test_result["testBaseInfo"] = test_case
         test_result["testStartTime"] = test_start_datetime
         test_results.append(test_result)
     return test_results
コード例 #2
0
 def execute_all_test_and_send_report(self, testing_case_model, test_report_model,
                                      project_id, executor_nick_name, execution_mode, project_name):
     test_results = []
     total_test_start_time = time.time()
     for test_case in self.test_case_list:
         backup_test_start = time.time()
         test_start_datetime = datetime.datetime.utcnow()
         test_result = self.execute_single_test(test_case)
         backup_test_end = time.time()
         backup_test_spending_time = round(backup_test_end - backup_test_start, 3)
         if 'lastManualTestResult' in test_case:
             test_case.pop('lastManualTestResult')
         domain = test_case["domain"] if 'domain' in test_case and isinstance(test_case["domain"], str) and \
                                         not test_case["domain"].strip() == '' else self.domain
         if 'requestProtocol' in test_case and 'route' in test_case:
             url = '%s://%s%s' % (test_case['requestProtocol'].lower(), domain, test_case['route'])
             test_case["url"] = url
         test_case['curl'] = common.generate_curl(method=test_case["requestMethod"],
                                                  url=test_case["url"],
                                                  headers=test_case["headers"],
                                                  data=test_case['presendParams'])
         test_result["spendingTimeInSec"] = test_case.pop(
             'spendingTimeInSec') if 'spendingTimeInSec' in test_case else backup_test_spending_time
         test_result["testBaseInfo"] = test_case
         test_result["testStartTime"] = test_start_datetime
         test_results.append(test_result)
     total_test_end_time = time.time()
     total_test_spending_time = round(total_test_end_time - total_test_start_time, 3)
     self.test_result_list = test_results
     self.update_case_info(testing_case_model)
     self.send_report(test_report_model, project_id, executor_nick_name, execution_mode, total_test_spending_time, project_name)
コード例 #3
0
 def execute_all_test_and_send_report(self, testing_case_model, test_report_model,
                                      project_id, executor_nick_name, execution_mode, project_name):
     test_results = []
     total_test_start_time = time.time()
     for index, test_case in enumerate(self.test_case_list):
         print(f'{executor_nick_name} 正在运行 {project_name} 测试项目,进度: {index+1} / {len(self.test_case_list)}')
         backup_test_start = time.time()
         test_start_datetime = datetime.datetime.utcnow()
         test_result = self.execute_single_test(test_case)
         backup_test_end = time.time()
         backup_test_spending_time = round(backup_test_end - backup_test_start, 3)
         if 'lastManualTestResult' in test_case:
             test_case.pop('lastManualTestResult')
         test_case['curl'] = common.generate_curl(method=test_case["requestMethod"],
                                                  url=test_case["url"],
                                                  headers=test_case["headers"],
                                                  data=test_case['presendParams'])
         test_result["spendingTimeInSec"] = test_case.pop(
             'spendingTimeInSec') if 'spendingTimeInSec' in test_case else backup_test_spending_time
         test_result["testBaseInfo"] = test_case
         test_result["testStartTime"] = test_start_datetime
         test_results.append(test_result)
     total_test_end_time = time.time()
     total_test_spending_time = round(total_test_end_time - total_test_start_time, 3)
     self.test_result_list = test_results
     self.update_case_info(testing_case_model)
     self.send_report(test_report_model, project_id, executor_nick_name, execution_mode, total_test_spending_time, project_name)
コード例 #4
0
 def execute_all_test_for_cron_and_single_test(self):
     test_results = []
     for test_case in self.test_case_list:
         backup_test_start = time.time()
         test_start_datetime = datetime.datetime.utcnow()
         test_result = self.execute_single_test(test_case)
         backup_test_end = time.time()
         backup_test_spending_time = round(backup_test_end - backup_test_start, 3)
         if 'lastManualTestResult' in test_case:
             test_case.pop('lastManualTestResult')
         test_case['curl'] = common.generate_curl(method=test_case["requestMethod"],
                                                  url=test_case["url"],
                                                  headers=test_case["headers"],
                                                  data=test_case['presendParams'])
         test_result["spendingTimeInSec"] = test_case.pop('spendingTimeInSec')\
             if 'spendingTimeInSec' in test_case else backup_test_spending_time
         test_result["testBaseInfo"] = test_case
         test_result["testStartTime"] = test_start_datetime
         test_results.append(test_result)
     return test_results