From 2a7383239469722ecc4422ae177f7b39ed1e7a73 Mon Sep 17 00:00:00 2001 From: Ev2geny Date: Thu, 16 Jul 2026 20:17:56 +0200 Subject: [PATCH 1/2] Add delete_rows_blocks, delete_columns_blocks and delete_dimension_blocks (issue #1589) New Worksheet methods that delete multiple non-contiguous blocks of rows or columns with a single batchUpdate API call and keep the cached row/column count in sync, unlike calling Spreadsheet.batch_update() directly. Tests added (cassettes to be recorded in a follow-up commit) --- gspread/worksheet.py | 152 ++++++++++++++++++++++++++++++++++++++++ tests/worksheet_test.py | 68 ++++++++++++++++++ 2 files changed, 220 insertions(+) diff --git a/gspread/worksheet.py b/gspread/worksheet.py index 1ae6337f..9dbe668d 100644 --- a/gspread/worksheet.py +++ b/gspread/worksheet.py @@ -2242,6 +2242,158 @@ def delete_columns( """ return self.delete_dimension(Dimension.cols, start_index, end_index) + def delete_dimension_blocks( + self, dimension: Dimension, blocks: Sequence[Sequence[int]] + ) -> JSONResponse: + """Deletes multiple non-contiguous blocks of rows or columns from + the worksheet with a single API call. + + :param dimension: A dimension to delete. ``Dimension.rows`` or ``Dimension.cols``. + :type dimension: :class:`~gspread.utils.Dimension` + :param blocks: A sequence of ``(start_index, end_index)`` pairs, one + per block to delete. Each block may be a tuple or a list of + exactly two ints. Indexes are 1-based and inclusive, consistent + with :meth:`~gspread.worksheet.Worksheet.delete_rows`. Blocks may + be listed in any order but must not overlap. + :type blocks: Sequence[Sequence[int]] + + :raises ValueError: If ``blocks`` is empty, a block does not contain + exactly 2 elements, a block has a start index lower than 1 or + greater than its end index, a block exceeds the current number + of rows/columns, or blocks overlap. + + .. versionadded:: 6.3.0 + """ + if dimension == Dimension.rows: + dimension_size = self.row_count + else: + dimension_size = self.col_count + + for block in blocks: + if len(block) != 2: + raise ValueError( + "block {} must contain exactly 2 elements: a start index and an end index".format( + block + ) + ) + + # blocks may mix lists and tuples, normalize to tuples before sorting + sorted_blocks = sorted((block[0], block[1]) for block in blocks) + self._validate_dimension_blocks(sorted_blocks, dimension, dimension_size) + + # delete bottom-most blocks first so that the indexes of the + # remaining blocks are not shifted by preceding deletions + body = { + "requests": [ + { + "deleteDimension": { + "range": { + "sheetId": self.id, + "dimension": dimension, + "startIndex": start_index - 1, + "endIndex": end_index, + } + } + } + for start_index, end_index in reversed(sorted_blocks) + ] + } + + res = self.client.batch_update(self.spreadsheet_id, body) + num_deleted = sum(end - start + 1 for start, end in sorted_blocks) + if dimension == Dimension.rows: + self._properties["gridProperties"]["rowCount"] -= num_deleted + elif dimension == Dimension.cols: + self._properties["gridProperties"]["columnCount"] -= num_deleted + return res + + @staticmethod + def _validate_dimension_blocks( + sorted_blocks: List[Tuple[int, int]], dimension: Dimension, dimension_size: int + ) -> None: + """Validates blocks for :meth:`~gspread.worksheet.Worksheet.delete_dimension_blocks`. + + ``sorted_blocks`` must already be sorted by start index. + + :raises ValueError: If the blocks are invalid, see + :meth:`~gspread.worksheet.Worksheet.delete_dimension_blocks`. + """ + if len(sorted_blocks) == 0: + raise ValueError("blocks must not be empty") + + for start_index, end_index in sorted_blocks: + if start_index < 1: + raise ValueError( + "block ({}, {}) has a start index lower than 1".format( + start_index, end_index + ) + ) + if end_index < start_index: + raise ValueError( + "block ({}, {}) has an end index lower than its start index".format( + start_index, end_index + ) + ) + if end_index > dimension_size: + raise ValueError( + "block ({}, {}) exceeds the worksheet size of {} {}".format( + start_index, end_index, dimension_size, dimension.name + ) + ) + for (_, previous_end), (next_start, _) in zip(sorted_blocks, sorted_blocks[1:]): + if next_start <= previous_end: + raise ValueError( + "blocks must not overlap: a block ending at {} overlaps a block starting at {}".format( + previous_end, next_start + ) + ) + + def delete_rows_blocks(self, blocks: Sequence[Sequence[int]]) -> JSONResponse: + """Deletes multiple non-contiguous blocks of rows from the worksheet + with a single API call. + + :param blocks: A sequence of ``(start_index, end_index)`` pairs, one + per block to delete. Each block may be a tuple or a list of + exactly two ints. Indexes are 1-based and inclusive, consistent + with :meth:`~gspread.worksheet.Worksheet.delete_rows`. Blocks may + be listed in any order but must not overlap. + :type blocks: Sequence[Sequence[int]] + + :raises ValueError: If the blocks are invalid, see + :meth:`~gspread.worksheet.Worksheet.delete_dimension_blocks`. + + Example:: + + # Delete rows 3 to 5 and rows 8 to 9 (inclusive) in one API call + worksheet.delete_rows_blocks([(3, 5), (8, 9)]) + + .. versionadded:: 6.3.0 + """ + return self.delete_dimension_blocks(Dimension.rows, blocks) + + def delete_columns_blocks(self, blocks: Sequence[Sequence[int]]) -> JSONResponse: + """Deletes multiple non-contiguous blocks of columns from the + worksheet with a single API call. + + :param blocks: A sequence of ``(start_index, end_index)`` pairs, one + per block to delete. Each block may be a tuple or a list of + exactly two ints. Indexes are 1-based and inclusive, consistent + with :meth:`~gspread.worksheet.Worksheet.delete_columns`. Blocks + may be listed in any order but must not overlap. + :type blocks: Sequence[Sequence[int]] + + :raises ValueError: If the blocks are invalid, see + :meth:`~gspread.worksheet.Worksheet.delete_dimension_blocks`. + + Example:: + + # Delete columns 3 to 5 and columns 8 to 9 (inclusive) in one API call + worksheet.delete_columns_blocks([(3, 5), (8, 9)]) + + .. versionadded:: 6.3.0 + """ + return self.delete_dimension_blocks(Dimension.cols, blocks) + def clear(self) -> JSONResponse: """Clears all cells in the worksheet.""" return self.client.values_clear( diff --git a/tests/worksheet_test.py b/tests/worksheet_test.py index c2567ae3..356a932c 100644 --- a/tests/worksheet_test.py +++ b/tests/worksheet_test.py @@ -1434,6 +1434,74 @@ def test_delete_cols(self): self.assertEqual(first_col_before, first_col_after) self.assertEqual(fourth_col_before, second_col_after) + @pytest.mark.vcr() + def test_delete_rows_blocks(self): + sequence_generator = self._sequence_generator() + num_rows = 10 + rows = [[next(sequence_generator)] for _ in range(num_rows)] + self.sheet.append_rows(rows) + + row_count_before = self.sheet.row_count + + # delete rows 3 to 5 and rows 8 to 9; + # blocks may be given in any order and mix lists and tuples + self.sheet.delete_rows_blocks([[8, 9], (3, 5)]) + + row_count_after = self.sheet.row_count + self.assertEqual(row_count_before - 5, row_count_after) + + expected_values = [rows[0], rows[1], rows[5], rows[6], rows[9]] + self.assertEqual(self.sheet.get_values("A1:A5"), expected_values) + + @pytest.mark.vcr() + def test_delete_columns_blocks(self): + sequence_generator = self._sequence_generator() + num_cols = 10 + row = [next(sequence_generator) for _ in range(num_cols)] + self.sheet.update([row], "A1:J1") + + col_count_before = self.sheet.col_count + + # delete columns 3 to 5 and columns 8 to 9; + # blocks may be given in any order and mix lists and tuples + self.sheet.delete_columns_blocks([[8, 9], (3, 5)]) + + col_count_after = self.sheet.col_count + self.assertEqual(col_count_before - 5, col_count_after) + + expected_values = [row[0], row[1], row[5], row[6], row[9]] + self.assertEqual(self.sheet.row_values(1), expected_values) + + @pytest.mark.vcr() + def test_delete_dimension_blocks_validation(self): + # empty blocks list + with self.assertRaises(ValueError): + self.sheet.delete_rows_blocks([]) + + # block does not contain exactly 2 elements + with self.assertRaises(ValueError): + self.sheet.delete_rows_blocks([(3, 5, 7)]) + with self.assertRaises(ValueError): + self.sheet.delete_rows_blocks([[3]]) + + # start index lower than 1 + with self.assertRaises(ValueError): + self.sheet.delete_rows_blocks([(0, 2)]) + + # end index lower than start index + with self.assertRaises(ValueError): + self.sheet.delete_rows_blocks([(5, 3)]) + + # block exceeds the worksheet size + with self.assertRaises(ValueError): + self.sheet.delete_rows_blocks([(1, self.sheet.row_count + 1)]) + with self.assertRaises(ValueError): + self.sheet.delete_columns_blocks([(1, self.sheet.col_count + 1)]) + + # overlapping blocks + with self.assertRaises(ValueError): + self.sheet.delete_rows_blocks([(3, 5), (5, 7)]) + @pytest.mark.vcr() def test_clear(self): rows = [ From 9bb394b528d307413e4fb472f399c63cc89aac0d Mon Sep 17 00:00:00 2001 From: Ev2geny Date: Thu, 16 Jul 2026 20:28:33 +0200 Subject: [PATCH 2/2] Cassets are recorded for the commit 2a73832 --- ...ksheetTest.test_delete_columns_blocks.json | 521 ++++++++++++++++++ ...st_delete_dimension_blocks_validation.json | 299 ++++++++++ ...WorksheetTest.test_delete_rows_blocks.json | 521 ++++++++++++++++++ 3 files changed, 1341 insertions(+) create mode 100644 tests/cassettes/WorksheetTest.test_delete_columns_blocks.json create mode 100644 tests/cassettes/WorksheetTest.test_delete_dimension_blocks_validation.json create mode 100644 tests/cassettes/WorksheetTest.test_delete_rows_blocks.json diff --git a/tests/cassettes/WorksheetTest.test_delete_columns_blocks.json b/tests/cassettes/WorksheetTest.test_delete_columns_blocks.json new file mode 100644 index 00000000..976d3eec --- /dev/null +++ b/tests/cassettes/WorksheetTest.test_delete_columns_blocks.json @@ -0,0 +1,521 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://www.googleapis.com/drive/v3/files?supportsAllDrives=True", + "body": "{\"name\": \"Test WorksheetTest test_delete_columns_blocks\", \"mimeType\": \"application/vnd.google-apps.spreadsheet\"}", + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "112" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin, X-Origin" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:04 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Pragma": [ + "no-cache" + ], + "content-length": [ + "199" + ] + }, + "body": { + "string": "{\n \"kind\": \"drive#file\",\n \"id\": \"102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA\",\n \"name\": \"Test WorksheetTest test_delete_columns_blocks\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:05 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "3343" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_delete_columns_blocks\",\n \"locale\": \"en_GB\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:06 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "3343" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_delete_columns_blocks\",\n \"locale\": \"en_GB\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "PUT", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA/values/%27Sheet1%27%21A1%3AJ1?valueInputOption=RAW", + "body": "{\"values\": [[\"test_delete_columns_blocks 1\", \"test_delete_columns_blocks 2\", \"test_delete_columns_blocks 3\", \"test_delete_columns_blocks 4\", \"test_delete_columns_blocks 5\", \"test_delete_columns_blocks 6\", \"test_delete_columns_blocks 7\", \"test_delete_columns_blocks 8\", \"test_delete_columns_blocks 9\", \"test_delete_columns_blocks 10\"]], \"majorDimension\": null}", + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "359" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:06 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "170" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA\",\n \"updatedRange\": \"Sheet1!A1:J1\",\n \"updatedRows\": 1,\n \"updatedColumns\": 10,\n \"updatedCells\": 10\n}\n" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA:batchUpdate", + "body": "{\"requests\": [{\"deleteDimension\": {\"range\": {\"sheetId\": 0, \"dimension\": \"COLUMNS\", \"startIndex\": 7, \"endIndex\": 9}}}, {\"deleteDimension\": {\"range\": {\"sheetId\": 0, \"dimension\": \"COLUMNS\", \"startIndex\": 2, \"endIndex\": 5}}}]}", + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "222" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:07 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "105" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA\",\n \"replies\": [\n {},\n {}\n ]\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA/values/%27Sheet1%27%21A1%3A1", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:08 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "279" + ] + }, + "body": { + "string": "{\n \"range\": \"Sheet1!A1:U1\",\n \"majorDimension\": \"ROWS\",\n \"values\": [\n [\n \"test_delete_columns_blocks 1\",\n \"test_delete_columns_blocks 2\",\n \"test_delete_columns_blocks 6\",\n \"test_delete_columns_blocks 7\",\n \"test_delete_columns_blocks 10\"\n ]\n ]\n}\n" + } + } + }, + { + "request": { + "method": "DELETE", + "uri": "https://www.googleapis.com/drive/v3/files/102zaKrWBOwRfnS4QfRAdmP9yzCQcg6W_-BqqEEZkwyA?supportsAllDrives=True", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 204, + "message": "No Content" + }, + "headers": { + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin, X-Origin" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "Content-Length": [ + "0" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:09 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Content-Type": [ + "text/html" + ], + "Pragma": [ + "no-cache" + ] + }, + "body": { + "string": "" + } + } + } + ] +} diff --git a/tests/cassettes/WorksheetTest.test_delete_dimension_blocks_validation.json b/tests/cassettes/WorksheetTest.test_delete_dimension_blocks_validation.json new file mode 100644 index 00000000..76a33c05 --- /dev/null +++ b/tests/cassettes/WorksheetTest.test_delete_dimension_blocks_validation.json @@ -0,0 +1,299 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://www.googleapis.com/drive/v3/files?supportsAllDrives=True", + "body": "{\"name\": \"Test WorksheetTest test_delete_dimension_blocks_validation\", \"mimeType\": \"application/vnd.google-apps.spreadsheet\"}", + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "125" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin, X-Origin" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:10 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Pragma": [ + "no-cache" + ], + "content-length": [ + "212" + ] + }, + "body": { + "string": "{\n \"kind\": \"drive#file\",\n \"id\": \"12XVkRoZzK4vij5L1GC1mBQQJ1c1WHGrlcjHd2LJ5mXM\",\n \"name\": \"Test WorksheetTest test_delete_dimension_blocks_validation\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/12XVkRoZzK4vij5L1GC1mBQQJ1c1WHGrlcjHd2LJ5mXM?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:11 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "3356" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"12XVkRoZzK4vij5L1GC1mBQQJ1c1WHGrlcjHd2LJ5mXM\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_delete_dimension_blocks_validation\",\n \"locale\": \"en_GB\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/12XVkRoZzK4vij5L1GC1mBQQJ1c1WHGrlcjHd2LJ5mXM/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/12XVkRoZzK4vij5L1GC1mBQQJ1c1WHGrlcjHd2LJ5mXM?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:12 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "3356" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"12XVkRoZzK4vij5L1GC1mBQQJ1c1WHGrlcjHd2LJ5mXM\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_delete_dimension_blocks_validation\",\n \"locale\": \"en_GB\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/12XVkRoZzK4vij5L1GC1mBQQJ1c1WHGrlcjHd2LJ5mXM/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "DELETE", + "uri": "https://www.googleapis.com/drive/v3/files/12XVkRoZzK4vij5L1GC1mBQQJ1c1WHGrlcjHd2LJ5mXM?supportsAllDrives=True", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 204, + "message": "No Content" + }, + "headers": { + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin, X-Origin" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "Content-Length": [ + "0" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:12 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Content-Type": [ + "text/html" + ], + "Pragma": [ + "no-cache" + ] + }, + "body": { + "string": "" + } + } + } + ] +} diff --git a/tests/cassettes/WorksheetTest.test_delete_rows_blocks.json b/tests/cassettes/WorksheetTest.test_delete_rows_blocks.json new file mode 100644 index 00000000..ad786ce1 --- /dev/null +++ b/tests/cassettes/WorksheetTest.test_delete_rows_blocks.json @@ -0,0 +1,521 @@ +{ + "version": 1, + "interactions": [ + { + "request": { + "method": "POST", + "uri": "https://www.googleapis.com/drive/v3/files?supportsAllDrives=True", + "body": "{\"name\": \"Test WorksheetTest test_delete_rows_blocks\", \"mimeType\": \"application/vnd.google-apps.spreadsheet\"}", + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "109" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin, X-Origin" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:15 GMT" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "Pragma": [ + "no-cache" + ], + "content-length": [ + "196" + ] + }, + "body": { + "string": "{\n \"kind\": \"drive#file\",\n \"id\": \"1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs\",\n \"name\": \"Test WorksheetTest test_delete_rows_blocks\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:15 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "3340" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_delete_rows_blocks\",\n \"locale\": \"en_GB\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs?includeGridData=false", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:15 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "3340" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs\",\n \"properties\": {\n \"title\": \"Test WorksheetTest test_delete_rows_blocks\",\n \"locale\": \"en_GB\",\n \"autoRecalc\": \"ON_CHANGE\",\n \"timeZone\": \"Etc/GMT\",\n \"defaultFormat\": {\n \"backgroundColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n },\n \"padding\": {\n \"top\": 2,\n \"right\": 3,\n \"bottom\": 2,\n \"left\": 3\n },\n \"verticalAlignment\": \"BOTTOM\",\n \"wrapStrategy\": \"OVERFLOW_CELL\",\n \"textFormat\": {\n \"foregroundColor\": {},\n \"fontFamily\": \"arial,sans,sans-serif\",\n \"fontSize\": 10,\n \"bold\": false,\n \"italic\": false,\n \"strikethrough\": false,\n \"underline\": false,\n \"foregroundColorStyle\": {\n \"rgbColor\": {}\n }\n },\n \"backgroundColorStyle\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n \"spreadsheetTheme\": {\n \"primaryFontFamily\": \"Arial\",\n \"themeColors\": [\n {\n \"colorType\": \"TEXT\",\n \"color\": {\n \"rgbColor\": {}\n }\n },\n {\n \"colorType\": \"BACKGROUND\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 1,\n \"blue\": 1\n }\n }\n },\n {\n \"colorType\": \"ACCENT1\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.25882354,\n \"green\": 0.52156866,\n \"blue\": 0.95686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT2\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.91764706,\n \"green\": 0.2627451,\n \"blue\": 0.20784314\n }\n }\n },\n {\n \"colorType\": \"ACCENT3\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.9843137,\n \"green\": 0.7372549,\n \"blue\": 0.015686275\n }\n }\n },\n {\n \"colorType\": \"ACCENT4\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.20392157,\n \"green\": 0.65882355,\n \"blue\": 0.3254902\n }\n }\n },\n {\n \"colorType\": \"ACCENT5\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 1,\n \"green\": 0.42745098,\n \"blue\": 0.003921569\n }\n }\n },\n {\n \"colorType\": \"ACCENT6\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.27450982,\n \"green\": 0.7411765,\n \"blue\": 0.7764706\n }\n }\n },\n {\n \"colorType\": \"LINK\",\n \"color\": {\n \"rgbColor\": {\n \"red\": 0.06666667,\n \"green\": 0.33333334,\n \"blue\": 0.8\n }\n }\n }\n ]\n }\n },\n \"sheets\": [\n {\n \"properties\": {\n \"sheetId\": 0,\n \"title\": \"Sheet1\",\n \"index\": 0,\n \"sheetType\": \"GRID\",\n \"gridProperties\": {\n \"rowCount\": 1000,\n \"columnCount\": 26\n }\n }\n }\n ],\n \"spreadsheetUrl\": \"https://docs.google.com/spreadsheets/d/1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs/edit\"\n}\n" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs/values/%27Sheet1%27:append?valueInputOption=RAW", + "body": "{\"values\": [[\"test_delete_rows_blocks 1\"], [\"test_delete_rows_blocks 2\"], [\"test_delete_rows_blocks 3\"], [\"test_delete_rows_blocks 4\"], [\"test_delete_rows_blocks 5\"], [\"test_delete_rows_blocks 6\"], [\"test_delete_rows_blocks 7\"], [\"test_delete_rows_blocks 8\"], [\"test_delete_rows_blocks 9\"], [\"test_delete_rows_blocks 10\"]]}", + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "323" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:16 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "267" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs\",\n \"updates\": {\n \"spreadsheetId\": \"1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs\",\n \"updatedRange\": \"Sheet1!A1:A10\",\n \"updatedRows\": 10,\n \"updatedColumns\": 1,\n \"updatedCells\": 10\n }\n}\n" + } + } + }, + { + "request": { + "method": "POST", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs:batchUpdate", + "body": "{\"requests\": [{\"deleteDimension\": {\"range\": {\"sheetId\": 0, \"dimension\": \"ROWS\", \"startIndex\": 7, \"endIndex\": 9}}}, {\"deleteDimension\": {\"range\": {\"sheetId\": 0, \"dimension\": \"ROWS\", \"startIndex\": 2, \"endIndex\": 5}}}]}", + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "216" + ], + "Content-Type": [ + "application/json" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:16 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "105" + ] + }, + "body": { + "string": "{\n \"spreadsheetId\": \"1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs\",\n \"replies\": [\n {},\n {}\n ]\n}\n" + } + } + }, + { + "request": { + "method": "GET", + "uri": "https://sheets.googleapis.com/v4/spreadsheets/1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs/values/%27Sheet1%27%21A1%3AA5", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 200, + "message": "OK" + }, + "headers": { + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "Transfer-Encoding": [ + "chunked" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin", + "X-Origin", + "Referer" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:16 GMT" + ], + "x-l2-request-path": [ + "l2-managed-6" + ], + "Content-Type": [ + "application/json; charset=UTF-8" + ], + "content-length": [ + "312" + ] + }, + "body": { + "string": "{\n \"range\": \"Sheet1!A1:A5\",\n \"majorDimension\": \"ROWS\",\n \"values\": [\n [\n \"test_delete_rows_blocks 1\"\n ],\n [\n \"test_delete_rows_blocks 2\"\n ],\n [\n \"test_delete_rows_blocks 6\"\n ],\n [\n \"test_delete_rows_blocks 7\"\n ],\n [\n \"test_delete_rows_blocks 10\"\n ]\n ]\n}\n" + } + } + }, + { + "request": { + "method": "DELETE", + "uri": "https://www.googleapis.com/drive/v3/files/1TQ1V0-5doz9wcU3LuNelYYZNsentku_lYg3ExaEIPAs?supportsAllDrives=True", + "body": null, + "headers": { + "User-Agent": [ + "python-requests/2.34.2" + ], + "Accept-Encoding": [ + "gzip, deflate" + ], + "Accept": [ + "*/*" + ], + "Connection": [ + "keep-alive" + ], + "Content-Length": [ + "0" + ], + "authorization": [ + "" + ] + } + }, + "response": { + "status": { + "code": 204, + "message": "No Content" + }, + "headers": { + "Expires": [ + "Mon, 01 Jan 1990 00:00:00 GMT" + ], + "X-Frame-Options": [ + "SAMEORIGIN" + ], + "X-XSS-Protection": [ + "0" + ], + "Server": [ + "ESF" + ], + "Vary": [ + "Origin, X-Origin" + ], + "Cache-Control": [ + "no-cache, no-store, max-age=0, must-revalidate" + ], + "Content-Length": [ + "0" + ], + "Date": [ + "Thu, 16 Jul 2026 18:22:17 GMT" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Alt-Svc": [ + "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000" + ], + "Content-Type": [ + "text/html" + ], + "Pragma": [ + "no-cache" + ] + }, + "body": { + "string": "" + } + } + } + ] +}