Skip to content

Commit

Permalink
Explicit test values for insert_records
Browse files Browse the repository at this point in the history
  • Loading branch information
muddi900 committed Nov 27, 2024
1 parent b4f68a8 commit 48679a3
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions tests/worksheet_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1803,17 +1803,22 @@ def test_append_records(self):
)

@pytest.mark.vcr()
def test_insert_rows(self):
def test_insert_records(self):
w = self.spreadsheet.sheet1
values = [
values_before = [
["header1", "header2"],
["value1", "value2"],
]
w.update(values_before, "A1:B2")
values_after = [
["header1", "header2"],
["value3", "value4"],
["", "value5"],
["value1", "value2"],
]
w.update(values, "A1:B2")
new_values = [values[0], ["value3", "value4"], ["", "value5"], *values[1:]]
self.assertEqual(
w.get_all_values(value_render_option=utils.ValueRenderOption.unformatted),
values,
values_before,
)

w.insert_records(
Expand All @@ -1825,21 +1830,29 @@ def test_insert_rows(self):

self.assertEqual(
w.get_all_values(value_render_option=utils.ValueRenderOption.unformatted),
new_values,
values_after,
)

with pytest.raises(GSpreadException):
w.insert_record({"header1": "error value1", "location": "error value2"})

w.insert_record(
{"header4": "ignore value", "header1": "value6", "header2": "value7"},
insert_row=5,
insert_row=4,
ignore_extra_headers=True,
)

values_after_single_entry = [
["header1", "header2"],
["value3", "value4"],
["", "value5"],
["value6", "value7"],
["value1", "value2"],
]

self.assertEqual(
w.get_all_values(),
[*new_values, ["value6", "value7"]],
values_after_single_entry,
)

@pytest.mark.vcr()
Expand Down

0 comments on commit 48679a3

Please sign in to comment.