def test_insert_single_sum_col(self): sheet = ExportSheet(ExportModel.from_json(ExportTestFixtures.model_1_json), 0) sheet.insert_row(["Heading"]) sheet.bump_row() sheet.insert_col([1, 2, 3]) sheet.bump_row() sheet.insert_single_sum("A2", "my_format") assert TestSheet.count_cells(sheet, formula="=SUM(A2:A4)") == 1
def test_bump_row(self): sheet = ExportSheet(ExportModel.from_json(ExportTestFixtures.model_1_json), 0) assert sheet.current_col == 0 sheet.current_col = 3 sheet.current_row = 4 sheet.bump_row(2) assert sheet.current_row == 6 assert sheet.current_col == 0
def test_insert_col_two_elements(self): sheet = ExportSheet(ExportModel.from_json(ExportTestFixtures.model_1_json), 0) assert len(sheet.cells) == 0 sheet.insert_col(["The Test", "A Second Test"], "my_format") assert TestSheet.count_cells(sheet, row=0, format_name="my_format", formula="The Test") == 1 assert TestSheet.count_cells(sheet, row=1, format_name="my_format", formula="A Second Test") == 1 assert sheet.current_col == 1 assert sheet.current_row == 0 sheet.bump_row() assert sheet.current_row == 2
def test_insert_sum_col(self): sheet = ExportSheet(ExportModel.from_json(ExportTestFixtures.model_1_json), 0) sheet.insert_row(["Col A", "Col B", "Col C", "Col D"]) sheet.bump_row() sheet.insert_col([1, 2, 3]) sheet.insert_col([4, 5, 6]) sheet.insert_col([7, 8, 9]) sheet.insert_col([10, 11, 12]) sheet.insert_sum_col(3, 4, "my_format") sheet.bump_row() assert TestSheet.count_cells(sheet, col=4, formula="=SUM(A2:D2)") == 1 assert TestSheet.count_cells(sheet, col=4, formula="=SUM(A3:D3)") == 1 assert TestSheet.count_cells(sheet, col=4, formula="=SUM(A4:D4)") == 1 assert TestSheet.count_cells(sheet, col=4) == 3
def test_insert_sum_row(self): sheet = ExportSheet(ExportModel.from_json(ExportTestFixtures.model_1_json), 0) sheet.insert_row(["Label", "Col A", "Col B", "Col C", "Col D"]) sheet.bump_row() sheet.insert_col(["Row A", "Row B", "Row C"]) sheet.insert_col([1, 2, 3]) sheet.insert_col([4, 5, 6]) sheet.insert_col([7, 8, 9]) sheet.insert_col([10, 11, 12]) sheet.bump_row() assert sheet.current_col == 0 sheet.insert_sum_row(3, 4, "my_format") assert TestSheet.count_cells(sheet, row=4, formula="=SUM(B2:B4)") == 1 assert TestSheet.count_cells(sheet, row=4, formula="=SUM(C2:C4)") == 1 assert TestSheet.count_cells(sheet, row=4, formula="=SUM(D2:D4)") == 1 assert TestSheet.count_cells(sheet, row=4, formula="=SUM(E2:E4)") == 1 assert TestSheet.count_cells(sheet, row=4) == 5