def test_block_cell(self): table = Table((0, 0), 10, 10) table.block_cell(1, 1, None, span=(3, 3)) cell = table.get_cell(1, 1) self.assertEqual(cell.span, (3, 3)) self.assertEqual(cell.blockdef, None) self.assertEqual(cell.stylename, 'default')
def test_default_text_cell(self): table = Table((0, 0), 10, 10) table.text_cell(0, 0, 'test') cell = table.get_cell(0, 0) self.assertEqual(cell.span, (1, 1)) self.assertEqual(cell.text, 'test') self.assertEqual(cell.stylename, 'default')
def test_text_cell(self): table = Table((0, 0), 10, 10) table.text_cell(8, 8, 'test88', span=(2, 2), style='extrastyle') cell = table.get_cell(8, 8) self.assertEqual(cell.span, (2, 2)) self.assertEqual(cell.text, 'test88') self.assertEqual(cell.stylename, 'extrastyle')
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__())