Exemplo n.º 1
0
    def test_cell_should_use_custom_alignment(self):

        table = Table(Canvas(), self.get_header(), row_height=10)

        with mock.patch(
                'reportlab.pdfgen.canvas.Canvas.beginText') as mock_obj:
            table.cell(2, 5, 'lorem ipsum', HAlign.CENTER, VAlign.MIDDLE)
            mock_obj.assert_called_once_with(242.3622047244094,
                                             637.0299212598425)
Exemplo n.º 2
0
    def test_cell_should_use_custom_padding(self):

        table = Table(Canvas(), self.get_header(), row_height=10)

        with mock.patch(
                'reportlab.pdfgen.canvas.Canvas.beginText') as mock_obj:
            table.cell(2, 5, 'lorem ipsum', padding=0)
            mock_obj.assert_called_once_with(240.94488188976374,
                                             645.2031496062991)
Exemplo n.º 3
0
    def test_cell_should_use_top_left_alignment_with_padding_by_default(self):

        table = Table(Canvas(), self.get_header(), row_height=10)

        with mock.patch(
                'reportlab.pdfgen.canvas.Canvas.beginText') as mock_obj:
            table.cell(2, 5, 'lorem ipsum')
            mock_obj.assert_called_once_with(242.3622047244094,
                                             643.7858267716535)
Exemplo n.º 4
0
    def test_cell_should_use_current_font(self):

        canvas = Canvas()
        canvas.font.family = FontFamily.SERIF
        canvas.font.weight = FontWeight.BOLD
        canvas.font.style = FontStyle.ITALIC
        canvas.font.size_mm = 5.5

        with mock.patch(
                'reportlab.pdfgen.canvas.Canvas.beginText') as mock_obj:
            table = Table(canvas, self.get_header(), row_height=10)
            table.cell(2, 5, 'lorem ipsum')
            mock_obj.return_value.setFont.assert_called_with(
                'FreeSerifBoldItalic', 15.590551181102363, 18.708661417322833)
Exemplo n.º 5
0
    def test_should_align_table_to_bottom_center(self, mock_grid):

        align = TableAlign(HAlign.CENTER, VAlign.BOTTOM, top=50, bottom=0.5)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [
                653.5275590551182, 625.1811023622048, 596.8346456692914,
                568.4881889763781, 540.1417322834646, 511.7952755905513,
                483.44881889763786, 455.1023622047245, 426.7559055118111,
                398.4094488188977, 370.0629921259843, 341.71653543307093,
                313.37007874015757, 285.02362204724415, 256.6771653543308,
                228.3307086614174, 199.984251968504, 171.6377952755906,
                143.2913385826772, 114.94488188976382, 86.59842519685043,
                58.25196850393704, 29.905511811023658, 1.5590551181102685
            ]),
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [696.0472440944883, 653.5275590551182])
        ], mock_grid.mock_calls)
Exemplo n.º 6
0
    def test_should_align_table_to_top_center(self, mock_grid):

        align = TableAlign(HAlign.CENTER, VAlign.TOP, top=0.5, bottom=50)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [
                797.5275590551181, 769.1811023622047, 740.8346456692913,
                712.4881889763778, 684.1417322834644, 655.7952755905511,
                627.4488188976377, 599.1023622047243, 570.7559055118109,
                542.4094488188975, 514.0629921259841, 485.71653543307076,
                457.37007874015734, 429.023622047244, 400.67716535433055,
                372.3307086614172, 343.98425196850377, 315.6377952755904,
                287.29133858267704, 258.9448818897636, 230.59842519685023,
                202.25196850393687, 173.90551181102347, 145.55905511811008
            ]),
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [840.0472440944882, 797.5275590551181])
        ], mock_grid.mock_calls)
Exemplo n.º 7
0
    def test_should_align_table_to_middle_center(self, mock_grid):

        align = TableAlign(HAlign.CENTER, VAlign.MIDDLE, top=10, bottom=50)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [
                711.496062992126, 683.1496062992126, 654.8031496062991,
                626.4566929133858, 598.1102362204724, 569.763779527559,
                541.4173228346457, 513.0708661417323, 484.72440944881885,
                456.3779527559055, 428.03149606299206, 399.6850393700787,
                371.33858267716533, 342.9921259842519, 314.64566929133855,
                286.29921259842513, 257.95275590551176, 229.60629921259837,
                201.25984251968498, 172.9133858267716, 144.5669291338582,
                116.22047244094482, 87.87401574803134
            ]),
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [754.0157480314962, 711.496062992126])
        ], mock_grid.mock_calls)
Exemplo n.º 8
0
    def test_should_align_table_to_top_right(self, mock_grid):

        align = TableAlign(HAlign.RIGHT,
                           VAlign.TOP,
                           right=0.5,
                           top=0.5,
                           bottom=50)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                83.19685039370064, 210.75590551181088, 281.62204724409435,
                366.6614173228345, 437.527559055118, 522.5669291338581,
                593.4330708661416
            ], [
                797.5275590551181, 769.1811023622047, 740.8346456692913,
                712.4881889763778, 684.1417322834644, 655.7952755905511,
                627.4488188976377, 599.1023622047243, 570.7559055118109,
                542.4094488188975, 514.0629921259841, 485.71653543307076,
                457.37007874015734, 429.023622047244, 400.67716535433055,
                372.3307086614172, 343.98425196850377, 315.6377952755904,
                287.29133858267704, 258.9448818897636, 230.59842519685023,
                202.25196850393687, 173.90551181102347, 145.55905511811008
            ]),
            mock.call([
                83.19685039370064, 210.75590551181088, 281.62204724409435,
                366.6614173228345, 437.527559055118, 522.5669291338581,
                593.4330708661416
            ], [840.0472440944882, 797.5275590551181])
        ], mock_grid.mock_calls)
Exemplo n.º 9
0
    def test_should_align_table_to_middle_right(self, mock_grid):

        align = TableAlign(HAlign.RIGHT,
                           VAlign.MIDDLE,
                           right=0.5,
                           top=10,
                           bottom=50)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                83.19685039370064, 210.75590551181088, 281.62204724409435,
                366.6614173228345, 437.527559055118, 522.5669291338581,
                593.4330708661416
            ], [
                711.496062992126, 683.1496062992126, 654.8031496062991,
                626.4566929133858, 598.1102362204724, 569.763779527559,
                541.4173228346457, 513.0708661417323, 484.72440944881885,
                456.3779527559055, 428.03149606299206, 399.6850393700787,
                371.33858267716533, 342.9921259842519, 314.64566929133855,
                286.29921259842513, 257.95275590551176, 229.60629921259837,
                201.25984251968498, 172.9133858267716, 144.5669291338582,
                116.22047244094482, 87.87401574803134
            ]),
            mock.call([
                83.19685039370064, 210.75590551181088, 281.62204724409435,
                366.6614173228345, 437.527559055118, 522.5669291338581,
                593.4330708661416
            ], [754.0157480314962, 711.496062992126])
        ], mock_grid.mock_calls)
Exemplo n.º 10
0
    def test_should_align_table_to_middle_left(self, mock_grid):

        align = TableAlign(HAlign.LEFT,
                           VAlign.MIDDLE,
                           left=0.5,
                           top=10,
                           bottom=50)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                1.8425196850393704, 129.40157480314963, 200.2677165354331,
                285.3070866141733, 356.17322834645677, 441.2125984251969,
                512.0787401574804
            ], [
                711.496062992126, 683.1496062992126, 654.8031496062991,
                626.4566929133858, 598.1102362204724, 569.763779527559,
                541.4173228346457, 513.0708661417323, 484.72440944881885,
                456.3779527559055, 428.03149606299206, 399.6850393700787,
                371.33858267716533, 342.9921259842519, 314.64566929133855,
                286.29921259842513, 257.95275590551176, 229.60629921259837,
                201.25984251968498, 172.9133858267716, 144.5669291338582,
                116.22047244094482, 87.87401574803134
            ]),
            mock.call([
                1.8425196850393704, 129.40157480314963, 200.2677165354331,
                285.3070866141733, 356.17322834645677, 441.2125984251969,
                512.0787401574804
            ], [754.0157480314962, 711.496062992126])
        ], mock_grid.mock_calls)
Exemplo n.º 11
0
    def test_should_restore_previous_state_after_rendering_table(self):

        canvas = Canvas()
        set_state(canvas, STATE_1)

        Table(canvas, self.get_header(), row_height=10)

        assert_same(self, STATE_1, get_state(canvas))
Exemplo n.º 12
0
    def test_should_render_body_header_and_column_titles_with_defaults(
            self, mock_grid, mock_begin_text):

        Table(Canvas(), self.get_header(), row_height=10)

        self.assertListEqual([
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [
                796.5354330708662, 768.1889763779528, 739.8425196850394,
                711.496062992126, 683.1496062992126, 654.8031496062991,
                626.4566929133858, 598.1102362204724, 569.763779527559,
                541.4173228346457, 513.0708661417323, 484.72440944881885,
                456.3779527559055, 428.03149606299206, 399.6850393700787,
                371.33858267716533, 342.9921259842519, 314.64566929133855,
                286.29921259842513, 257.95275590551176, 229.60629921259837,
                201.25984251968498, 172.9133858267716, 144.5669291338582,
                116.22047244094482, 87.87401574803134, 59.527559055117955,
                31.181102362204566, 2.8346456692911777
            ]),
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [839.0551181102363, 796.5354330708662])
        ], mock_grid.mock_calls)

        self.assertListEqual([
            mock.call(42.51968503937, 815.244094488189),
            mock.call(170.07874015748024, 820.3464566929134),
            mock.call(240.94488188976374, 820.3464566929134),
            mock.call(325.9842519685039, 820.3464566929134),
            mock.call(396.8503937007874, 820.3464566929134),
            mock.call(481.8897637795275, 820.3464566929134)
        ], mock_begin_text.call_args_list)
Exemplo n.º 13
0
 def setUp(self):
     self.table = Table(Canvas(), self.get_header(), row_height=10)
Exemplo n.º 14
0
class TestTable(unittest.TestCase):
    def setUp(self):
        self.table = Table(Canvas(), self.get_header(), row_height=10)

    def test_should_restore_previous_state_after_rendering_table(self):

        canvas = Canvas()
        set_state(canvas, STATE_1)

        Table(canvas, self.get_header(), row_height=10)

        assert_same(self, STATE_1, get_state(canvas))

    @mock.patch('reportlab.pdfgen.canvas.Canvas.beginText')
    @mock.patch('reportlab.pdfgen.canvas.Canvas.grid')
    def test_should_render_body_header_and_column_titles_with_defaults(
            self, mock_grid, mock_begin_text):

        Table(Canvas(), self.get_header(), row_height=10)

        self.assertListEqual([
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [
                796.5354330708662, 768.1889763779528, 739.8425196850394,
                711.496062992126, 683.1496062992126, 654.8031496062991,
                626.4566929133858, 598.1102362204724, 569.763779527559,
                541.4173228346457, 513.0708661417323, 484.72440944881885,
                456.3779527559055, 428.03149606299206, 399.6850393700787,
                371.33858267716533, 342.9921259842519, 314.64566929133855,
                286.29921259842513, 257.95275590551176, 229.60629921259837,
                201.25984251968498, 172.9133858267716, 144.5669291338582,
                116.22047244094482, 87.87401574803134, 59.527559055117955,
                31.181102362204566, 2.8346456692911777
            ]),
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [839.0551181102363, 796.5354330708662])
        ], mock_grid.mock_calls)

        self.assertListEqual([
            mock.call(42.51968503937, 815.244094488189),
            mock.call(170.07874015748024, 820.3464566929134),
            mock.call(240.94488188976374, 820.3464566929134),
            mock.call(325.9842519685039, 820.3464566929134),
            mock.call(396.8503937007874, 820.3464566929134),
            mock.call(481.8897637795275, 820.3464566929134)
        ], mock_begin_text.call_args_list)

    @mock.patch('reportlab.pdfgen.canvas.Canvas.grid')
    def test_should_align_table_to_top_left(self, mock_grid):

        align = TableAlign(HAlign.LEFT,
                           VAlign.TOP,
                           left=0.5,
                           top=0.5,
                           bottom=50)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                1.8425196850393704, 129.40157480314963, 200.2677165354331,
                285.3070866141733, 356.17322834645677, 441.2125984251969,
                512.0787401574804
            ], [
                797.5275590551181, 769.1811023622047, 740.8346456692913,
                712.4881889763778, 684.1417322834644, 655.7952755905511,
                627.4488188976377, 599.1023622047243, 570.7559055118109,
                542.4094488188975, 514.0629921259841, 485.71653543307076,
                457.37007874015734, 429.023622047244, 400.67716535433055,
                372.3307086614172, 343.98425196850377, 315.6377952755904,
                287.29133858267704, 258.9448818897636, 230.59842519685023,
                202.25196850393687, 173.90551181102347, 145.55905511811008
            ]),
            mock.call([
                1.8425196850393704, 129.40157480314963, 200.2677165354331,
                285.3070866141733, 356.17322834645677, 441.2125984251969,
                512.0787401574804
            ], [840.0472440944882, 797.5275590551181])
        ], mock_grid.mock_calls)

    @mock.patch('reportlab.pdfgen.canvas.Canvas.grid')
    def test_should_align_table_to_middle_left(self, mock_grid):

        align = TableAlign(HAlign.LEFT,
                           VAlign.MIDDLE,
                           left=0.5,
                           top=10,
                           bottom=50)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                1.8425196850393704, 129.40157480314963, 200.2677165354331,
                285.3070866141733, 356.17322834645677, 441.2125984251969,
                512.0787401574804
            ], [
                711.496062992126, 683.1496062992126, 654.8031496062991,
                626.4566929133858, 598.1102362204724, 569.763779527559,
                541.4173228346457, 513.0708661417323, 484.72440944881885,
                456.3779527559055, 428.03149606299206, 399.6850393700787,
                371.33858267716533, 342.9921259842519, 314.64566929133855,
                286.29921259842513, 257.95275590551176, 229.60629921259837,
                201.25984251968498, 172.9133858267716, 144.5669291338582,
                116.22047244094482, 87.87401574803134
            ]),
            mock.call([
                1.8425196850393704, 129.40157480314963, 200.2677165354331,
                285.3070866141733, 356.17322834645677, 441.2125984251969,
                512.0787401574804
            ], [754.0157480314962, 711.496062992126])
        ], mock_grid.mock_calls)

    @mock.patch('reportlab.pdfgen.canvas.Canvas.grid')
    def test_should_align_table_to_bottom_left(self, mock_grid):

        align = TableAlign(HAlign.LEFT,
                           VAlign.BOTTOM,
                           left=0.5,
                           top=50,
                           bottom=0.5)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                1.8425196850393704, 129.40157480314963, 200.2677165354331,
                285.3070866141733, 356.17322834645677, 441.2125984251969,
                512.0787401574804
            ], [
                653.5275590551182, 625.1811023622048, 596.8346456692914,
                568.4881889763781, 540.1417322834646, 511.7952755905513,
                483.44881889763786, 455.1023622047245, 426.7559055118111,
                398.4094488188977, 370.0629921259843, 341.71653543307093,
                313.37007874015757, 285.02362204724415, 256.6771653543308,
                228.3307086614174, 199.984251968504, 171.6377952755906,
                143.2913385826772, 114.94488188976382, 86.59842519685043,
                58.25196850393704, 29.905511811023658, 1.5590551181102685
            ]),
            mock.call([
                1.8425196850393704, 129.40157480314963, 200.2677165354331,
                285.3070866141733, 356.17322834645677, 441.2125984251969,
                512.0787401574804
            ], [696.0472440944883, 653.5275590551182])
        ], mock_grid.mock_calls)

    @mock.patch('reportlab.pdfgen.canvas.Canvas.grid')
    def test_should_align_table_to_top_right(self, mock_grid):

        align = TableAlign(HAlign.RIGHT,
                           VAlign.TOP,
                           right=0.5,
                           top=0.5,
                           bottom=50)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                83.19685039370064, 210.75590551181088, 281.62204724409435,
                366.6614173228345, 437.527559055118, 522.5669291338581,
                593.4330708661416
            ], [
                797.5275590551181, 769.1811023622047, 740.8346456692913,
                712.4881889763778, 684.1417322834644, 655.7952755905511,
                627.4488188976377, 599.1023622047243, 570.7559055118109,
                542.4094488188975, 514.0629921259841, 485.71653543307076,
                457.37007874015734, 429.023622047244, 400.67716535433055,
                372.3307086614172, 343.98425196850377, 315.6377952755904,
                287.29133858267704, 258.9448818897636, 230.59842519685023,
                202.25196850393687, 173.90551181102347, 145.55905511811008
            ]),
            mock.call([
                83.19685039370064, 210.75590551181088, 281.62204724409435,
                366.6614173228345, 437.527559055118, 522.5669291338581,
                593.4330708661416
            ], [840.0472440944882, 797.5275590551181])
        ], mock_grid.mock_calls)

    @mock.patch('reportlab.pdfgen.canvas.Canvas.grid')
    def test_should_align_table_to_middle_right(self, mock_grid):

        align = TableAlign(HAlign.RIGHT,
                           VAlign.MIDDLE,
                           right=0.5,
                           top=10,
                           bottom=50)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                83.19685039370064, 210.75590551181088, 281.62204724409435,
                366.6614173228345, 437.527559055118, 522.5669291338581,
                593.4330708661416
            ], [
                711.496062992126, 683.1496062992126, 654.8031496062991,
                626.4566929133858, 598.1102362204724, 569.763779527559,
                541.4173228346457, 513.0708661417323, 484.72440944881885,
                456.3779527559055, 428.03149606299206, 399.6850393700787,
                371.33858267716533, 342.9921259842519, 314.64566929133855,
                286.29921259842513, 257.95275590551176, 229.60629921259837,
                201.25984251968498, 172.9133858267716, 144.5669291338582,
                116.22047244094482, 87.87401574803134
            ]),
            mock.call([
                83.19685039370064, 210.75590551181088, 281.62204724409435,
                366.6614173228345, 437.527559055118, 522.5669291338581,
                593.4330708661416
            ], [754.0157480314962, 711.496062992126])
        ], mock_grid.mock_calls)

    @mock.patch('reportlab.pdfgen.canvas.Canvas.grid')
    def test_should_align_table_to_bottom_right(self, mock_grid):

        align = TableAlign(HAlign.RIGHT,
                           VAlign.BOTTOM,
                           right=0.5,
                           top=50,
                           bottom=0.5)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                83.19685039370064, 210.75590551181088, 281.62204724409435,
                366.6614173228345, 437.527559055118, 522.5669291338581,
                593.4330708661416
            ], [
                653.5275590551182, 625.1811023622048, 596.8346456692914,
                568.4881889763781, 540.1417322834646, 511.7952755905513,
                483.44881889763786, 455.1023622047245, 426.7559055118111,
                398.4094488188977, 370.0629921259843, 341.71653543307093,
                313.37007874015757, 285.02362204724415, 256.6771653543308,
                228.3307086614174, 199.984251968504, 171.6377952755906,
                143.2913385826772, 114.94488188976382, 86.59842519685043,
                58.25196850393704, 29.905511811023658, 1.5590551181102685
            ]),
            mock.call([
                83.19685039370064, 210.75590551181088, 281.62204724409435,
                366.6614173228345, 437.527559055118, 522.5669291338581,
                593.4330708661416
            ], [696.0472440944883, 653.5275590551182])
        ], mock_grid.mock_calls)

    @mock.patch('reportlab.pdfgen.canvas.Canvas.grid')
    def test_should_align_table_to_top_center(self, mock_grid):

        align = TableAlign(HAlign.CENTER, VAlign.TOP, top=0.5, bottom=50)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [
                797.5275590551181, 769.1811023622047, 740.8346456692913,
                712.4881889763778, 684.1417322834644, 655.7952755905511,
                627.4488188976377, 599.1023622047243, 570.7559055118109,
                542.4094488188975, 514.0629921259841, 485.71653543307076,
                457.37007874015734, 429.023622047244, 400.67716535433055,
                372.3307086614172, 343.98425196850377, 315.6377952755904,
                287.29133858267704, 258.9448818897636, 230.59842519685023,
                202.25196850393687, 173.90551181102347, 145.55905511811008
            ]),
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [840.0472440944882, 797.5275590551181])
        ], mock_grid.mock_calls)

    @mock.patch('reportlab.pdfgen.canvas.Canvas.grid')
    def test_should_align_table_to_middle_center(self, mock_grid):

        align = TableAlign(HAlign.CENTER, VAlign.MIDDLE, top=10, bottom=50)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [
                711.496062992126, 683.1496062992126, 654.8031496062991,
                626.4566929133858, 598.1102362204724, 569.763779527559,
                541.4173228346457, 513.0708661417323, 484.72440944881885,
                456.3779527559055, 428.03149606299206, 399.6850393700787,
                371.33858267716533, 342.9921259842519, 314.64566929133855,
                286.29921259842513, 257.95275590551176, 229.60629921259837,
                201.25984251968498, 172.9133858267716, 144.5669291338582,
                116.22047244094482, 87.87401574803134
            ]),
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [754.0157480314962, 711.496062992126])
        ], mock_grid.mock_calls)

    @mock.patch('reportlab.pdfgen.canvas.Canvas.grid')
    def test_should_align_table_to_bottom_center(self, mock_grid):

        align = TableAlign(HAlign.CENTER, VAlign.BOTTOM, top=50, bottom=0.5)

        Table(Canvas(), self.get_header(), 10, align)

        self.assertListEqual([
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [
                653.5275590551182, 625.1811023622048, 596.8346456692914,
                568.4881889763781, 540.1417322834646, 511.7952755905513,
                483.44881889763786, 455.1023622047245, 426.7559055118111,
                398.4094488188977, 370.0629921259843, 341.71653543307093,
                313.37007874015757, 285.02362204724415, 256.6771653543308,
                228.3307086614174, 199.984251968504, 171.6377952755906,
                143.2913385826772, 114.94488188976382, 86.59842519685043,
                58.25196850393704, 29.905511811023658, 1.5590551181102685
            ]),
            mock.call([
                42.51968503937, 170.07874015748024, 240.94488188976374,
                325.9842519685039, 396.8503937007874, 481.8897637795275,
                552.755905511811
            ], [696.0472440944883, 653.5275590551182])
        ], mock_grid.mock_calls)

    def test_cell_should_reject_invalid_column_index(self):
        with self.assertRaises(AssertionError):
            self.table.cell(6, 0, 'lorem ipsum')

    def test_cell_should_reject_invalid_row_index(self):
        with self.assertRaises(AssertionError):
            self.table.cell(0, 28, 'lorem ipsum')

    def test_cell_should_use_top_left_alignment_with_padding_by_default(self):

        table = Table(Canvas(), self.get_header(), row_height=10)

        with mock.patch(
                'reportlab.pdfgen.canvas.Canvas.beginText') as mock_obj:
            table.cell(2, 5, 'lorem ipsum')
            mock_obj.assert_called_once_with(242.3622047244094,
                                             643.7858267716535)

    def test_cell_should_use_custom_alignment(self):

        table = Table(Canvas(), self.get_header(), row_height=10)

        with mock.patch(
                'reportlab.pdfgen.canvas.Canvas.beginText') as mock_obj:
            table.cell(2, 5, 'lorem ipsum', HAlign.CENTER, VAlign.MIDDLE)
            mock_obj.assert_called_once_with(242.3622047244094,
                                             637.0299212598425)

    def test_cell_should_use_custom_padding(self):

        table = Table(Canvas(), self.get_header(), row_height=10)

        with mock.patch(
                'reportlab.pdfgen.canvas.Canvas.beginText') as mock_obj:
            table.cell(2, 5, 'lorem ipsum', padding=0)
            mock_obj.assert_called_once_with(240.94488188976374,
                                             645.2031496062991)

    def test_cell_should_use_current_font(self):

        canvas = Canvas()
        canvas.font.family = FontFamily.SERIF
        canvas.font.weight = FontWeight.BOLD
        canvas.font.style = FontStyle.ITALIC
        canvas.font.size_mm = 5.5

        with mock.patch(
                'reportlab.pdfgen.canvas.Canvas.beginText') as mock_obj:
            table = Table(canvas, self.get_header(), row_height=10)
            table.cell(2, 5, 'lorem ipsum')
            mock_obj.return_value.setFont.assert_called_with(
                'FreeSerifBoldItalic', 15.590551181102363, 18.708661417322833)

    def get_header(self, height=15):

        columns = [
            Column(45, 'lorem'),
            Column(25, 'ipsum dolor sit amet'),
            Column(30, 'consectetur adipisicing elit'),
            Column(25, 'incididunt ut labore'),
            Column(30, 'et dolore magna aliqua ut'),
            Column(25, 'enim ad minim veniam')
        ]

        return Header(height, columns)