def __get_summary_files(config: dict) -> List[Path]: summary_files = [] for run in config['runs']: file_path = resolve_path(run['fullPath']) / SUMMARY_FILE_NAME validate_file_exists(file_path, f"File {file_path} does not exists") summary_files.append(resolve_path(run['fullPath']) / SUMMARY_FILE_NAME) return summary_files
def __get_data_to_write(config: dict) -> List[dict]: __validate_count_of_actions(config) column_value_by_label_list = [] column_name = config['column_name'] for run in config['runs']: column_value_by_label = {} filename = resolve_path(run['fullPath']) / RESULTS_CSV_FILE_NAME with filename.open(mode='r') as fs: for row in csv.DictReader(fs): column_value_by_label[row['Label']] = row[column_name] column_value_by_label_list.append(column_value_by_label) return column_value_by_label_list
def __get_tests_results(config: dict) -> List[dict]: results_files_list = [] column_name = config['column_name'] for run in config['runs']: value_by_action = {} absolute_file_path = resolve_path( run['fullPath']) / RESULTS_CSV_FILE_NAME with absolute_file_path.open(mode='r') as fs: for row in csv.DictReader(fs): value_by_action[row['Label']] = row[column_name] results_files_list.append( ResultsCSV(absolute_file_path=absolute_file_path, actions=value_by_action)) return results_files_list
def __validate_count_of_actions(key_files: dict): # TODO consider doing validation and reading file avoiding opening the same file two times (see __get_data_to_write) counter = 0 counter_dict = {} for run in key_files['runs']: filename = resolve_path(run['fullPath']) / RESULTS_CSV_FILE_NAME with filename.open(mode='r') as f: records = csv.DictReader(f) row_count = sum(1 for _ in records) counter_dict[filename] = row_count if counter == 0: counter = row_count if row_count != counter: for filename, actions in counter_dict.items(): print(f'Result file {filename} has {actions} actions\n') raise SystemExit( 'Incorrect number of actions. ' 'The number of actions should be the same for each results.csv.' )