def get_row_data( self, row_comparison, columns, include_columns=None, exclude_columns=None, display_index=False, ): """Return single row data to be printed""" result = [] for idx, column in enumerate(columns): actual = row_comparison.data[idx] other, matched = row_comparison.get_comparison_value(column, idx) value_limit = int((constants.CELL_STRING_LENGTH - 4) / 2) other, actual = format_cell_data(data=[other, actual], limit=value_limit) include_columns = include_columns or columns exclude_columns = exclude_columns or [] if (column not in include_columns) or (column in exclude_columns): result.append("{} .. {}".format(actual, other)) elif matched: result.append(Color.green("{} == {}".format(actual, other))) else: result.append(Color.red("{} != {}".format(actual, other))) if display_index: result = [row_comparison.idx] + result return result
def get_matched_row_data(self, row_comparison, columns, include_columns, exclude_columns, row_idx): """ Return a single row of data in the correct match format and the RowStyles indicating which cells need to be coloured red. Sample output: [{'name': Susan == Susan, 'age': 24 == 24}] and [RowStyle(...), ...] :param row_comparison: RowComparison object containing this rows data. :type row_comparison: ``testplan.testing.multitest .entries.assertions.RowComparison`` :param columns: List of the displayed columns. :type columns: ``list`` :param row_idx: Index of the row being compared. This is not the same as other row_idx parameters in this module. Those refer to the row index of the global table used to display everything in the PDF report. :type row_idx: ``int`` :param include_columns: :type include_columns: :param exclude_columns: :type exclude_columns: :return: A single row of the matched data in tabular format and the RowStyles indicating which cells need to be coloured red. :rtype: ``list`` of ``dict`` and ``list`` of ``testplan.common.exporters.pdf.RowStyle`` """ result = {} colour_row = [] for idx, column in enumerate(columns): actual = row_comparison.data[idx] other, matched = row_comparison.get_comparison_value(column, idx) value_limit = int((const.CELL_STRING_LENGTH - 4) / 2) other, actual = format_cell_data( data=[other, actual], limit=value_limit ) other = "REGEX('{}')".format( other.pattern) if is_regex(other) else other include_columns = include_columns or columns exclude_columns = exclude_columns or [] if (column not in include_columns) or (column in exclude_columns): result[column] = '{} .. {}'.format(actual, other) colour_row.append('I') elif matched: result[column] = '{} == {}'.format(actual, other) colour_row.append('P') else: result[column] = '{} != {}'.format(actual, other) colour_row.append('F') return result, colour_row