Skip to content

Commit

Permalink
Creted a test for batch_merge
Browse files Browse the repository at this point in the history
  • Loading branch information
muddi900 committed Aug 2, 2024
1 parent 3e875da commit 93e6483
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/worksheet_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,43 @@ def test_get_values_and_combine_merged_cells(self):
values_with_merged = self.sheet.get_values("A1:D4", combine_merged_cells=True)
self.assertEqual(values_with_merged, expected_merge)

@pytest.mark.vcr()
def test_batch_merged_cells(self):
self.sheet.resize(4, 4)
sheet_data = [
["1", "", "", ""],
["", "", "title", ""],
["", "", "2", ""],
["num", "val", "", "0"],
]

self.sheet.update(sheet_data, "A1:D4")

self.sheet.batch_merge(
[
{"range": "A1:B2"},
{"range": "C2:D2"},
{"range": "C3:C4"},
]
)

expected_merge = [
["1", "1", "", ""],
["1", "1", "title", "title"],
["", "", "2", ""],
["num", "val", "2", "0"],
]

values = self.sheet.get_values()
values_with_merged = self.sheet.get_values(combine_merged_cells=True)

self.assertEqual(values, sheet_data)
self.assertEqual(values_with_merged, expected_merge)

# test with cell address
values_with_merged = self.sheet.get_values("A1:D4", combine_merged_cells=True)
self.assertEqual(values_with_merged, expected_merge)

@pytest.mark.vcr()
def test_get_values_with_args_or_kwargs(self):
# test that get_values accepts args and kwargs
Expand Down

0 comments on commit 93e6483

Please sign in to comment.