コード例 #1
0
    def get_detail(self, source, depth, row_idx):
        row_style = RowStyle(
            left_padding=const.INDENT * (depth + 1),
            font=(const.FONT, const.FONT_SIZE_SMALL)
        )
        table_style = format_table_style(const.DISPLAYED_TABLE_STYLE)

        raw_table = []
        row_indices = []
        colour_matrix = []
        for comp_obj in source['data']:
            row = {
                source['column']: comp_obj[1],
                'Passed': 'Pass' if comp_obj[2] else 'Fail'
            }
            raw_table.append(row)
            row_indices.append(comp_obj[0])
            colour_matrix.append(['I', 'P' if comp_obj[2] else 'F'])

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

        data = [['Values: {}'.format(source['values']), '', '', '']] + table
        return RowData(content=data, start=row_idx, style=row_style)
コード例 #2
0
ファイル: assertions.py プロジェクト: morganstanley/testplan
    def get_detail(self, source, depth, row_idx):
        row_style = RowStyle(
            left_padding=const.INDENT * (depth + 1),
            font=(const.FONT, const.FONT_SIZE_SMALL),
        )
        table_style = format_table_style(const.DISPLAYED_TABLE_STYLE)

        raw_table = []
        row_indices = []
        colour_matrix = []
        for comp_obj in source["data"]:
            row = [comp_obj[1], "Pass" if comp_obj[2] else "Fail"]
            raw_table.append(row)
            row_indices.append(comp_obj[0])
            colour_matrix.append(["I", "P" if comp_obj[2] else "F"])

        max_width = const.PAGE_WIDTH - (depth * const.INDENT)
        table = create_table(
            table=raw_table,
            columns=[source["column"], "Passed"],
            row_indices=row_indices,
            display_index=source["report_fails_only"],
            max_width=max_width,
            style=table_style,
            colour_matrix=colour_matrix,
        )

        data = [["Values: {}".format(source["values"]), "", "", ""]] + table
        return RowData(content=data, start=row_idx, style=row_style)
コード例 #3
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
コード例 #4
0
ファイル: base.py プロジェクト: fukaij/testplan
    def get_row_data(self, source, depth, row_idx):
        """
        Reformat the rows from the serialized data into a format ReportLab
        accepts. Create a header and a ReportLab table and add it to the row.
        """
        header = self.get_header(source, depth, row_idx)
        row_style = [RowStyle(left_padding=constants.INDENT * (depth + 1))]
        table_style = format_table_style(constants.DISPLAYED_TABLE_STYLE)

        max_width = constants.PAGE_WIDTH - (depth * constants.INDENT)
        table = create_table(table=source['table'],
                             columns=source['columns'],
                             row_indices=source['indices'],
                             display_index=source['display_index'],
                             max_width=max_width,
                             style=table_style)

        return header + RowData(
            content=table, start=header.end, style=row_style)