def test_table_object_table_builder_does_build_headings_from_grouped_table(
        stub_grouped_table_object):
    # given - a table without a category_caption value
    builder = TableObjectTableBuilder()
    table_object = stub_grouped_table_object
    table_object["category_caption"] = "expected caption"

    # when we process the object as a table
    data = builder.get_data_table(table_object)
    headers = data[0:2]

    # then the header for the returned table should match the ones we would expect from this table
    expected_headers = [["", "Men", "", "Women", ""],
                        ["expected caption", "Value", "Rate", "Value", "Rate"]]
    assert expected_headers == headers
def test_table_object_table_builder_does_build_data_for_rows(
        stub_grouped_table_object):
    # given - a table without a category_caption value
    builder = TableObjectTableBuilder()
    table_object = stub_grouped_table_object
    table_object.pop("category_caption")

    # when we process the object as a table
    data = builder.get_data_table(table_object)
    data.pop(0)
    data.pop(0)

    # then the header for the returned table should match the ones we would expect from this tabl
    expected_rows = [["White", "25.6", "0.256", "12.8", "0.128"],
                     ["Other", "16.6", "0.166", "10.0", "0.100"]]
    assert expected_rows == data
def test_table_object_table_builder_does_build_categories_as_row_captions(
        stub_grouped_table_object):
    # given - a table without a category_caption value
    builder = TableObjectTableBuilder()
    table_object = stub_grouped_table_object
    table_object.pop("category_caption")

    # when we process the object as a table
    data = builder.get_data_table(table_object)
    data.pop(0)
    data.pop(0)
    categories = [row[0] for row in data]

    # then the header for the returned table should match the ones we would expect from this tabl
    expected_categories = ["White", "Other"]
    assert expected_categories == categories
Example #4
0
    def build(dimension):
        dimension_object = {
            "context": DimensionObjectBuilder.get_context(dimension)
        }

        if dimension.table:
            dimension_object["table"] = TableObjectDataBuilder.build(
                dimension.table)

        if dimension.chart:
            dimension_object["chart"] = ChartObjectDataBuilder.build(
                dimension.chart)

        if dimension.table:
            dimension_object["tabular"] = TableObjectTableBuilder.build(
                dimension.table)

        return dimension_object
Example #5
0
    def build(dimension):
        dimension_object = {
            "context": DimensionObjectBuilder.get_context(dimension)
        }

        if dimension.dimension_table and dimension.dimension_table.table_object:
            dimension_object["table"] = TableObjectDataBuilder.build(
                dimension.dimension_table.table_object)

        if dimension.dimension_chart and dimension.dimension_chart.chart_object:
            dimension_object["chart"] = ChartObjectDataBuilder.build(
                dimension.dimension_chart.chart_object)

        if dimension.dimension_table and dimension.dimension_table.table_object:
            dimension_object["tabular"] = TableObjectTableBuilder.build(
                dimension.dimension_table.table_object)

        return dimension_object