def handle_no_cases_to_run_with_api(self, file_from_api: bool, test_data_m: TestDataManager, result_matrix: list, cases_matrix: list): if not file_from_api and len(cases_matrix) is 0 and InitUtils.get_bool_variable( AutomationConstants.SEND_CSV, test_data_m.get_config_data()): self.send_all_csv_report() elif file_from_api and len(cases_matrix) is 0: os.makedirs(test_data_m.get_report_path(), exist_ok=True) FileUtils.write_matrix_to_csv_file(test_data_m.get_report_path() + test_data_m.get_timestamp() + '.cvs', result_matrix)
def __update_result_matrix(self): if self.__get_result_matrix() is not None: try: self.__logger.begin() info_string: str = self.get_test_data_manager( ).case_variables_to_string(self.__test_id) if info_string is not None: info_string += ', ' add_browser_to_matrix: bool = AutomationConstants.BROWSER in self.__get_result_matrix( )[0] browser_string = ("browser: " + self.__browser + ", " if self.__browser and add_browser_to_matrix else '') self.__logger.info(info_string + browser_string + "time: " + str(self.__duration) + (", report: " + str(self.__last_exception) if self. __last_exception and not self.__result == AutomationConstants.TEST_SUCCESS else '')) self.__get_result_matrix()[int(self.__test_id) + 1] = \ self.__get_execution_result_array(add_browser_to_matrix) print(self.__get_result_matrix()) self.__logger.info( 'Saving result as ' + self.get_test_data_manager().get_timestamp() + '.csv') os.makedirs(self.get_report_path(), exist_ok=True) FileUtils.write_matrix_to_csv_file( self.get_report_path() + self.get_test_data_manager().get_timestamp() + '.csv', self.__get_result_matrix()) self.__suite_m.update_test_finished(self.__test_case) self.__logger.end() except IOError as e: self.__logger.print_stack_trace(e) self.__logger.end() raise IOError
def write_matrix_to_csv_file(file_path: str, matrix: list): FileUtils.write_matrix_to_csv_file(InteractionObject.get_path_with_resources(file_path), matrix)