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_insert_row_two_elements(self): sheet = ExportSheet(ExportModel.from_json(ExportTestFixtures.model_1_json), 0) assert len(sheet.cells) == 0 sheet.insert_row(["The Test", "A Second Test"], "my_format") assert TestSheet.count_cells(sheet, col=0, format_name="my_format", formula="The Test") == 1 assert TestSheet.count_cells(sheet, col=1, format_name="my_format", formula="A Second Test") == 1 assert sheet.current_col == 2 assert sheet.current_row == 0
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
def test_insert_single_sum_row(self): sheet = ExportSheet(ExportModel.from_json(ExportTestFixtures.model_1_json), 0) sheet.insert_row([1, 2, 3]) sheet.insert_single_sum("A1", "my_format") assert TestSheet.count_cells(sheet, formula="=SUM(A1:C1)") == 1
def test_insert_row_basic(self): sheet = ExportSheet(ExportModel.from_json(ExportTestFixtures.model_1_json), 0) assert len(sheet.cells) == 0 sheet.insert_row(["The Test"]) assert TestSheet.count_cells(sheet, formula="The Test") == 1 assert sheet.current_col == 1