Skip to content

Commit

Permalink
added a test for set_records.
Browse files Browse the repository at this point in the history
  • Loading branch information
muddi900 committed Jul 21, 2024
1 parent e39932b commit a926e54
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/worksheet_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,27 @@ def test_batch_clear(self):
self.assertListEqual(w.get_values("A1:B1"), [[]])
self.assertListEqual(w.get_values("C2:E2"), [[]])

@pytest.mark.vcr()
def test_set_records(self):

w = self.spreadsheet.sheet1
values = [["name", "age"], ["jean", 44]]
w.update(values, "A1:B2")
self.assertEqual(w.get_all_values(), values)
update_values = [{"name": "john", "age": 11}, {"name": "abdullah"}]
w.set_records(update_values)
values = [*values, ["john", 11], ["abdullah", ""]]
self.assertEqual(w.get_all_values(), values)
with self.assertRaises(GSpreadException) as ar:
w.set_record({"name": "lin", "location": "helsinki"})

self.assertEqual(ar.exception, GSpreadException)
w.set_record(
{"name": "juanita", "status": "active", "age": 33},
ignore_extra_headers=True,
)
self.assertEqual(w.get_all_values(), [*values, ["juanita", 33]])

@pytest.mark.vcr()
def test_group_columns(self):
w = self.sheet
Expand Down

0 comments on commit a926e54

Please sign in to comment.