コード例 #1
0
    def _create_test_case_wrapper(self, timestamp: str, test_case: str, relevant_column: int) -> HtmlElement:
        wrapper = None
        final_path = self._report_path + timestamp + ".csv"

        if os.path.exists(final_path):
            wrapper = (HtmlElement("div")
                       .add_attr("id", test_case))

            self._data_matrix = FileUtils.csv_file_to_matrix(final_path)
            self._data_matrix = ArrayUtils.remove_rows_containing(self._data_matrix,
                                                                  AutomationConstants.TEST_UNDONE, -3)

            if len(self._data_matrix) > 1:
                try:
                    self._test_stats = self._initialize_dictionary(self._data_matrix)
                    self._column_cases_order: dict = self._get_column_order(self._data_matrix)

                    self._copy_images_folder(self._report_path, self._test_stats)

                    relevant_column = self._update_relevant_column(relevant_column)

                    results_dict = self._test_stats[self._data_matrix[0][-3]]

                    n_success = results_dict[AutomationConstants.TEST_SUCCESS][0]\
                        if AutomationConstants.TEST_SUCCESS in results_dict else 0
                    n_failures = results_dict[AutomationConstants.TEST_FAILURE][1]\
                        if AutomationConstants.TEST_FAILURE in results_dict else 0

                    wrapper_color = CsvToHtml._get_wrapper_color(n_success, n_failures)

                    wrapper.add_attr("class", "wrapper column accordion bg-light-" + wrapper_color)

                    wrapper.add_child(self._create_header(test_case, n_success, n_failures, wrapper_color))

                    accordion_content = (HtmlElement("section")
                                         .add_attr("class", "columns ac-content"))

                    self._add_relevant_tables(accordion_content, relevant_column)

                    if self._column_cases_order[AutomationConstants.RESULT]\
                            .__contains__(AutomationConstants.TEST_FAILURE):
                        accordion_content.add_child(
                            self._get_error_report_node(self._data_matrix, self._report_path, timestamp))

                    self._modify_accordion_content(accordion_content, timestamp, test_case, relevant_column)

                    wrapper.add_child(accordion_content)
                except Exception as e:
                    self._print_stack_trace(e)

            self._modify_wrapper_content(wrapper, timestamp, test_case, relevant_column)

        return wrapper
コード例 #2
0
 def csv_file_to_matrix(file_path: str):
     return FileUtils.csv_file_to_matrix(InteractionObject.get_path_with_resources(file_path))
コード例 #3
0
    def get_result_matrix_from_csv_file(file_path):
        file_path = file_path if file_path.endswith(".csv") else file_path + ".csv"

        return FileUtils.csv_file_to_matrix(file_path)
コード例 #4
0
 def set_case_variables(self, test_data_path: str, test_data_m: TestDataManager):
     if test_data_path is not None:
         test_data_m.set_case_variables(FileUtils.csv_file_to_matrix(test_data_path, True)[0])
     else:
         test_data_m.set_case_variables(['id'])