Ejemplo n.º 1
0
    def get_detail(self, source, depth, row_idx):
        row_style = [RowStyle(left_padding=const.INDENT * (depth + 1))]
        table_style = format_table_style(const.DISPLAYED_TABLE_STYLE)

        raw_table = []
        row_indices = []
        colour_matrix = []
        for i, row_comparison_data in enumerate(source['data']):
            row_comparison = assertions.RowComparison(*row_comparison_data)
            row, colour_row = self.get_matched_row_data(
                row_comparison=row_comparison,
                columns=source['columns'],
                include_columns=source['include_columns'],
                exclude_columns=source['exclude_columns'],
                row_idx=i
            )
            raw_table.append(row)
            row_indices.append(row_comparison.idx)
            colour_matrix.append(colour_row)

        max_width = const.PAGE_WIDTH - (depth * const.INDENT)
        table = create_table(
            table=raw_table,
            columns=source['columns'],
            row_indices=row_indices,
            display_index=source['report_fails_only'],
            max_width=max_width,
            style=table_style,
            colour_matrix=colour_matrix
        ) if raw_table else None

        if source['message']:
            error_style = row_style + [RowStyle(
                font=(const.FONT, const.FONT_SIZE_SMALL),
                textcolor=colors.black if source['passed'] else colors.red)]
            error = RowData(
                content=source['message'],
                start=row_idx,
                style=error_style
            )
            # The error style isn't applied to the error string, possible bug.
            return error + RowData(
                content=table,
                start=error.end,
                style=row_style
            ) if table else error
        else:
            return RowData(content=table, start=row_idx, style=row_style) \
                if table else None
Ejemplo n.º 2
0
     {
         'foo': 3,
         'bar': 4
     },
 ], [
     {
         'foo': 1,
         'bar': 2
     },
     {
         'foo': 3,
         'bar': 4
     },
 ], ['foo', 'bar'], ['foo', 'bar'], True, 0,
  (True, [
      assertions.RowComparison(0, [1, 2], {}, {}, {}),
      assertions.RowComparison(1, [3, 4], {}, {}, {}),
  ])],
 # Basic failure, bar column mismatch
 [[
     {
         'foo': 1,
         'bar': 2
     },
     {
         'foo': 3,
         'bar': 4
     },
 ], [
     {
         'foo': 1,
Ejemplo n.º 3
0
)

COMPARE_ROWS_PARAMS = [
    # Basic match, all columns same
    [
        [{"foo": 1, "bar": 2}, {"foo": 3, "bar": 4}],
        [{"foo": 1, "bar": 2}, {"foo": 3, "bar": 4}],
        ["foo", "bar"],
        ["foo", "bar"],
        True,
        0,
        False,
        (
            True,
            [
                assertions.RowComparison(0, [1, 2], {}, {}, {}),
                assertions.RowComparison(1, [3, 4], {}, {}, {}),
            ],
        ),
    ],
    # Basic failure, bar column mismatch
    [
        [{"foo": 1, "bar": 2}, {"foo": 3, "bar": 4}],
        [{"foo": 1, "bar": 2}, {"foo": 3, "bar": 5}],
        ["foo", "bar"],
        ["foo", "bar"],
        True,
        0,
        False,
        (
            False,