Example #1
0
 def test_dxf_creation_span(self):
     self.reset_counter()
     table = Table((0, 0), 3, 3)
     indices = [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0),
                (2, 1), (2, 2)]
     cell = UserCell(table, 'default', (1, 1))
     for row, col in indices:
         table.set_cell(row, col, cell)
     spancell = UserCell(table, 'default', span=(2, 2))  # hides 3 cells
     table.set_cell(0, 0, spancell)
     table.__dxf__()
     dxfmock = DXFMock()
     self.assertEqual(cell.counter, 6)  # count get_dxf_entity calls
     self.assertEqual(cell.counter, dxfmock.counter)
Example #2
0
 def test_dxf_creation_span(self):
     self.reset_counter()
     table = Table((0, 0), 3, 3)
     indices = [(0, 0), (0, 1), (0, 2),
                (1, 0), (1, 1), (1, 2),
                (2, 0), (2, 1), (2, 2)]
     cell = TestCell(table, 'default', (1, 1))
     for row, col in indices:
         table.set_cell(row, col, cell)
     spancell = TestCell(table, 'default', span=(2, 2)) # hides 3 cells
     table.set_cell(0, 0, spancell)
     table.__dxf__()
     dxfmock = DXFMock()
     self.assertEqual(cell.counter, 6) # count get_dxf_entity calls
     self.assertEqual(cell.counter, dxfmock.counter)
Example #3
0
class TestGrid(unittest.TestCase):
    def setUp(self):
        self.table = Table((0, 0), 3, 3)
        for x in range(3):
            self.table.set_col_width(x, 3.0)
            self.table.set_row_height(x, 3.0)

    def test_grid_coords(self):
        grid = Grid(self.table)
        left, right, top, bottom = grid.cell_coords(1, 1, span=(1, 1))
        self.assertAlmostEqual(left, 3., places=4)
        self.assertAlmostEqual(right, 6., places=4)
        self.assertAlmostEqual(top, -3., places=4)
        self.assertAlmostEqual(bottom, -6., places=4)

    def test_grid_coords_span(self):
        grid = Grid(self.table)
        left, right, top, bottom = grid.cell_coords(0, 0, span=(2, 2))
        self.assertAlmostEqual(left, 0., places=4)
        self.assertAlmostEqual(right, 6., places=4)
        self.assertAlmostEqual(top, 0., places=4)
        self.assertAlmostEqual(bottom, -6., places=4)

    def test_draw_cell_background(self):
        grid = Grid(self.table)
        self.table.new_cell_style('fill', bgcolor=17)

        cell = self.table.get_cell(0, 0)
        cell.stylename='fill'

        self.assertTrue('SOLID' in self.table.__dxf__())