Skip to content

Commit

Permalink
made test values more generic.
Browse files Browse the repository at this point in the history
  • Loading branch information
muddi900 authored Jul 23, 2024
1 parent 4a6ecf8 commit a377b0a
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions tests/worksheet_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1675,29 +1675,46 @@ def test_batch_clear(self):
def test_set_records(self):

w = self.spreadsheet.sheet1
values = [["name", "age"], ["jean", 44]]
values = [
["header1", "header2"],
["value1", "value2"],
]
w.update(values, "A1:B2")
self.assertEqual(
w.get_all_values(value_render_option=utils.ValueRenderOption.unformatted),
values,
)
update_values = [{"name": "john", "age": 11}, {"name": "abdullah"}]
update_values = [
{"header1": "new value1", "header2": "new value2"},
{"header1": "new value3"},
]
w.set_records(update_values)
values = [*values, ["john", 11], ["abdullah", ""]]
new_values = [
*values,
["new value1", "new value2"],
["new value3", ""],
]
self.assertEqual(
w.get_all_values(value_render_option=utils.ValueRenderOption.unformatted),
values,
new_values,
)
with pytest.raises(GSpreadException):
w.set_record({"name": "lin", "location": "helsinki"})
w.set_record({"header1": "error value1", "location": "error value2"})

w.set_record(
{"name": "juanita", "status": "active", "age": 33},
{
"header1": "single entry1",
"status": "active",
"header2": "single entry2",
},
ignore_extra_headers=True,
)
self.assertEqual(
w.get_all_values(value_render_option=utils.ValueRenderOption.unformatted),
[*values, ["juanita", 33]],
[
*new_values,
["single entry1", "single entry2"],
],
)

@pytest.mark.vcr()
Expand Down

0 comments on commit a377b0a

Please sign in to comment.