Beispiel #1
0
def test_creation_of_report_layout_full():
    report = Report(*_transform('grid_checks/fullgrid.json'))
    report.populate_report()

    d = report.document
    table = next(utils.iter_block_items(d))
    assert isinstance(table, Table)
    assert len(table.columns) == 12
    assert len(table.rows) == 12

    # Check the specific merged cells
    vtable = [
        [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
        [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
        [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0],
        [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    ]
    assert get_vtable_merged(table) == vtable

    # Check the page breaks
    assert len(d.element.xpath('//w:pgSz[@w:orient="landscape"]')) == 0

    # Check page size
    page_sz = d.element.xpath('//w:pgSz[@w:w]')
    assert len(page_sz) == 1
    page_sz = page_sz[0]
    width, height = int(page_sz.w.mm), int(page_sz.h.mm)
    expected_width, expected_height = A4_MM_WIDTH.mm, A4_MM_HEIGHT.mm

    # Conversions aren't exact, so we are looking for a close enough difference.
    assert abs(expected_width - width) < 2
    assert abs(expected_height - height) < 2
Beispiel #2
0
def test_creation_of_report_layout_basic():
    report = Report(*_transform('basic.json'))
    report.populate_report()

    d = report.document
    table = next(utils.iter_block_items(d))
    assert isinstance(table, Table)
    assert len(table.columns) == 12
    assert len(table.rows) == 2

    # Check the specific merged cells
    vtable = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
    assert get_vtable_merged(table) == vtable
Beispiel #3
0
def test_creation_of_report_layout_full_paged():
    report = Report(*_transform('grid_checks/fullgridpaged.json'))
    report.populate_report()

    d = report.document
    table = next(utils.iter_block_items(d))
    assert isinstance(table, Table)
    assert len(table.columns) == 12
    assert len(table.rows) == 11

    # Check the specific merged cells
    vtable = [
        [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
        [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
        [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    ]
    assert get_vtable_merged(table) == vtable

    # Check the page breaks
    assert len(d.element.xpath('//w:br')) == 1