Beispiel #1
0
 def test_gettablesize_singlecolumn(self):
     """ Tests that single column tables work """
     tests.basicsetup(self)
     ## This uses the first column of the greedycolumn table
     sheet = self.sheet_Tables4
     r1,c1 = 1,1
     self.assertEqual(Tables.gettablesize(sheet, c1, r1), "A1:A3")
Beispiel #2
0
 def test_gettablesize_notable(self):
     """ Tests that gettablesize on a blank row/column results in None"""
     tests.basicsetup(self)
     ## This uses the blank space between the two greedy table tests
     sheet = self.sheet_Tables4
     r1, c1 = 1,10
     self.assertIsNone(Tables.gettablesize(sheet, c1, r1))
Beispiel #3
0
 def test_gettablesize_blank_rows(self):
     """ Tests gettablesize with blank rows """
     tests.basicsetup(self)
     sheet = self.sheet_Tables4
     r1, c1 = 1,11
     for (greedyrows,result) in [(1,"K1:N4"),(2, "K1:N7")]:
         with self.subTest(greedyrows = greedyrows, result = result):
             self.assertEqual(Tables.gettablesize(sheet, c1, r1, greedyrows=greedyrows), result)
Beispiel #4
0
 def test_gettablesize_blank_columns(self):
     """ Tests gettablesize with blank columns """
     tests.basicsetup(self)
     sheet = self.sheet_Tables4
     r1, c1 = 1,1
     for (greedycolumns,result) in [(1,"A1:C3"),(2, "A1:G3")]:
         with self.subTest(greedycolumns = greedycolumns, result = result):
             self.assertEqual(Tables.gettablesize(sheet, c1, r1, greedycolumns=greedycolumns), result)
Beispiel #5
0
 def test_get_table_by_name(self):
     """ Basic Tests for get_table_by_name """
     tests.basicsetup(self)
     sheet = self.sheet_Tables1
     name = 'testtable_1'
     table = Tables.get_table_by_name(sheet,name)
     self.assertIsInstance(table,openpyxl.worksheet.table.Table)
     import collections
     self.assertEqual(dict(a = 1),collections.OrderedDict([("a",1),]))
     dicts = Tables.EnhancedTable.from_table(table,sheet).todicts()
     self.assertEqual(Tables.EnhancedTable.from_table(table,sheet).todicts(),[["Name","Value"],dict(Name="Hello",Value = 1),dict(Name="World",Value=2)])
Beispiel #6
0
 def test_dicts_to_table_simple_add(self):
     """ A simple test to add a new table based on dicts to a worksheet """
     tests.basicsetup(self)
     ws = self.workbook.create_sheet("testsheet")
     testdata = [dict(a = 1, b = 1, c = 1),
                 dict(a = 2, b = 2, c = 2),
                 dict(a = 3, b = 3, c = 3)]
     table = Tables.dicts_to_table(ws, testdata, start = "$A$1")
     testrange = AL_Excel.Range(ws,Tables.gettablesize(ws,1,1))
     self.assertEqual(testrange.startcoord,AL_Excel.Coordinate("A1"))
     self.assertEqual(testrange.endcoord,AL_Excel.Coordinate("C4"))
     output = table.todicts()[1:]
     self.assertEqual(len(output),len(testdata))
     self.assertEqual(output,testdata)
Beispiel #7
0
 def setUp(self):
     tests.basicsetup(self)
Beispiel #8
0
 def setUp(self):
     tests.basicsetup(self)
     return super().setUp()
Beispiel #9
0
 def setUp(self):
     tests.basicsetup(self)
     self.tables = {table.name:table for worksheet,table in Tables.get_all_tables(self.workbook)}
     return super().setUp()
Beispiel #10
0
 def test_gettablesize(self):
     """ Tests gettablesize for a variety of table shapes """
     tests.basicsetup(self)
     sheet = self.sheet_Tables3
     r1,c1 = 2,3
     self.assertEqual(Tables.gettablesize(sheet,c1,r1),"C2:F15")