Ejemplo n.º 1
0
 def test_split_heading_match(self):
     sheet1 = sheet_from_file('data/schools.xlsx', 6, 6)
     sheet2 = sheet_from_file('data/schools.xlsx', 7, 7)
     sheets = [sheet1, sheet2]
     index_locations = get_index_locations(sheets)
     matches = match(sheets)
     sheet_blocks = split_blocks(sheet1, matches, index_locations)
     print(sheet_blocks)
     self.assertEqual(len(sheet_blocks), 3)
Ejemplo n.º 2
0
 def test_match_actual(self):
     sheet1 = sheet_from_file('data/schools.xlsx', 0, 0)
     sheet2 = sheet_from_file('data/schools.xlsx', 1, 1)
     matches = match([sheet1, sheet2])
     print(matches)
     expected = sorted([('i_1_00_003', 'i_0_00_004'),
                        ('i_1_00_002', 'i_0_00_002'),
                        ('i_1_00_005', 'i_0_00_006'),
                        ('i_1_00_004', 'i_0_00_005'),
                        ('j_1_00_005', 'j_0_00_002')])
     self.assertEqual(sorted(matches), expected)
Ejemplo n.º 3
0
 def test_split_actual_match(self):
     sheet1 = sheet_from_file('data/schools.xlsx', 0, 0)
     sheet2 = sheet_from_file('data/schools.xlsx', 1, 1)
     matches = match([sheet1, sheet2])
     index_locations = get_index_locations([sheet1, sheet2])
     blocks = split_blocks(sheet1, matches, index_locations)
     print(matches)
     print(blocks)
     self.assertEqual(len(blocks), 11)
     self.assertEqual(len(blocks[0].cells), 2)
     self.assertEqual(
         blocks[1].types,
         {'italics', 'color_3_0_7999816888943144', 'theme_3', 'bold'})
     self.assertEqual(len(blocks[1].cells), 1)
Ejemplo n.º 4
0
 def test_split_heading(self):
     sheet = sheet_from_file('data/schools.xlsx', 6, 6)
     index_locations = get_index_locations([sheet])
     matches = {}
     sheet_blocks = split_blocks(sheet, matches, index_locations)
     print(sheet_blocks)
     self.assertEqual(len(sheet_blocks), 2)
Ejemplo n.º 5
0
 def test_create_blocks(self):
     sheet = sheet_from_file('data/schools.xlsx', 0, 0)
     index_locations = get_index_locations([sheet])
     matches = {}
     blocks = split_blocks(sheet, matches, index_locations)
     gblocks = generalise(blocks)
     output_blocks = create_blocks(gblocks, matches)
     self.assertEqual(len(output_blocks), 9)
Ejemplo n.º 6
0
 def test_split_empty(self):
     sheet = sheet_from_file('data/schools.xlsx', 5, 0)
     index_map = sheet.index_map
     matches = {}
     index_locations = {v: k for k, v in index_map.items()}
     print(index_locations)
     blocks = split_blocks(sheet, matches, index_locations)
     print(blocks)
     self.assertEqual(len(blocks), 1)
     self.assertEqual(len(blocks[0].cells), 12)
Ejemplo n.º 7
0
 def test_generalise(self):
     sheet = sheet_from_file('data/schools.xlsx', 0, 0)
     index_locations = get_index_locations([sheet])
     matches = {}
     blocks = split_blocks(sheet, matches, index_locations)
     gblocks = generalise(blocks)
     print(gblocks)
     self.assertEqual(len(gblocks), 8)
     self.assertIsInstance(gblocks[-1], FormulaBlockHorizontal)
     self.assertEqual(
         gblocks[-1].dependant_types,
         {'color_3_0_3999755851924192', 'color_3_0_5999938962981048'})
     self.assertIsInstance(gblocks[-2], FormulaBlockVertical)
Ejemplo n.º 8
0
 def test_csp(self):
     sheet = sheet_from_file('data/schools.xlsx', 0, 0)
     index_locations = get_index_locations([sheet])
     matches = {}
     blocks = split_blocks(sheet, matches, index_locations)
     output_blocks = create_blocks(blocks, matches)
     assignment = csp(output_blocks, [sheet], matches)
     expected = {
         'i_0_00_001': 8,
         'i_0_00_003': 10,
         'i_0_00_004': 11,
         'i_0_00_006': 13,
         'i_0_01_007': 14,
         'j_0_00_001': 12,
         'j_0_00_002': 13,
         'j_0_00_003': 14,
         'j_0_00_005': 16,
         'j_0_00_006': 17,
         'j_0_01_001': 12
     }
     self.assertEqual(assignment, expected)
Ejemplo n.º 9
0
 def test_sheet_from_file(self):
     sheet = sheet_from_file('data/schools.xlsx', 0, 4)
     self.assertEqual(len(sheet.cells), 105)
     self.assertEqual(len(sheet.index_map), 105)