Commit c0cf667
fix(google-sheets): upgrade to SDK 2.0.0, fix Lambda crash on error paths (#289)
* fix(google-sheets): upgrade to SDK 2.0.0, fix Lambda crash on error paths, add unit tests
Converts all error paths from ActionResult(data={error, result: False}) to
ActionError(message=...) to fix output schema validation crashes in SDK 2.0.0.
Removes error/result fields from all output schemas. Adds 51 pytest unit tests.
* fix(google-sheets): fix auth to use .get(), add integration test, update .env.example
- Fix build_credentials to use context.auth.get("credentials", {}).get("access_token", "")
- Add test_google_sheets_integration.py with GOOGLE_SHEETS_ACCESS_TOKEN skip guard
- Add GOOGLE_SHEETS_ACCESS_TOKEN and GOOGLE_SHEETS_TEST_SPREADSHEET_ID to .env.example
- Apply ruff format to all google-sheets files
* fix(google-sheets): fix optional param access and ruff formatting
* fix(google-sheets): add full integration tests for all 10 actions
* chore(google-sheets): remove legacy test file replaced by test_google_sheets_integration.py
* fix(google-sheets): use 'is not None' for pageSize/pageToken truthy check
A pageSize of 0 (or pageToken of empty string) was previously dropped by
the truthy check. Use 'is not None' so explicit falsy values still flow
through to the Drive API request.
* refactor(google-sheets): drop importlib boilerplate from unit tests
- conftest.py now adds the integration root to sys.path (was a no-op
inserting tests/ which exposed nothing useful).
- Each unit test file replaces the spec_from_file_location dance with a
plain 'from google_sheets import google_sheets'.
- @patch targets switch from per-file unique mod names back to
'google_sheets.build'.
- Delete stale tests/context.py (pre-SDK-2.0 testbed shim, no longer
imported anywhere).
* fix(google-sheets): assert ResultType.ACTION in destructive integration tests
'result.result is not None' is always true (it's ActionResultData on
success or ActionErrorData on failure), so the destructive tests for
sheets_format_range, sheets_freeze, and sheets_batch_update would pass
even when the action returned an ActionError. Assert on result.type
instead so the tests fail when the action errors.
* chore(google-sheets): remove dead get_first_spreadsheet_id helper
The helper was never called — every test inlined the
sheets_list_spreadsheets call directly. It also used the deprecated
asyncio.get_event_loop().run_until_complete() pattern, which would
clash with pytest-asyncio's loop if it ever were invoked.
* refactor(google-sheets): drop importlib boilerplate from integration tests
Mirrors the unit test refactor in 3a33344 — replace the
spec_from_file_location dance with 'from google_sheets import google_sheets'
and remove the now-redundant inline ResultType import in
TestDuplicateSpreadsheet.
* fix(google-sheets): escape single quotes in owner email q-string
The 'owner' input is interpolated unescaped into the Drive q-string,
which would break (and could in principle inject into) the query for
emails containing apostrophes. Mirror the existing escape applied to
'name_contains'.
* chore(google-sheets): remove unreachable validation in sheets_batch_update
The handler's 'requests must be a list of dicts' check is unreachable:
the SDK validates the input schema before the handler runs and returns
a VALIDATION_ERROR for non-list / non-dict-item inputs. The two existing
unit tests confirm this — both still pass and assert
ResultType.VALIDATION_ERROR coming from the SDK layer.
* test(google-sheets): cover pageSize/pageToken, build_credentials, rich format style
- TestListSpreadsheets: assert pageSize and pageToken reach
drive.files().list(**params) when supplied. Closes the 1% coverage
gap and locks in the 'is not None' fix from 5e9f80a.
- TestBuildCredentials: direct tests for the empty-string fallback
paths added to build_credentials so a regression to bracket
indexing on missing 'credentials' or 'access_token' is caught.
- TestFormatRange: richer style payload (background + textFormat +
alignment) flows through to userEnteredFormat unchanged, and the
request range merges sheetId with the gridRange.
---------
Co-authored-by: Shubhank <72601061+Sagsgit@users.noreply.github.com>
Co-authored-by: Kai Koenig <kai@ventego-creative.co.nz>1 parent 99129aa commit c0cf667
11 files changed
Lines changed: 1428 additions & 510 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
42 | 40 | | |
43 | | - | |
| 41 | + | |
44 | 42 | | |
45 | 43 | | |
46 | 44 | | |
| |||
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
63 | | - | |
64 | | - | |
65 | | - | |
| 61 | + | |
66 | 62 | | |
67 | | - | |
| 63 | + | |
68 | 64 | | |
69 | 65 | | |
70 | 66 | | |
| |||
80 | 76 | | |
81 | 77 | | |
82 | 78 | | |
83 | | - | |
84 | | - | |
85 | | - | |
| 79 | + | |
86 | 80 | | |
87 | | - | |
| 81 | + | |
88 | 82 | | |
89 | 83 | | |
90 | 84 | | |
| |||
119 | 113 | | |
120 | 114 | | |
121 | 115 | | |
122 | | - | |
123 | | - | |
124 | | - | |
| 116 | + | |
125 | 117 | | |
126 | | - | |
| 118 | + | |
127 | 119 | | |
128 | 120 | | |
129 | 121 | | |
| |||
153 | 145 | | |
154 | 146 | | |
155 | 147 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 148 | + | |
| 149 | + | |
161 | 150 | | |
162 | 151 | | |
163 | 152 | | |
| |||
185 | 174 | | |
186 | 175 | | |
187 | 176 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 177 | + | |
| 178 | + | |
193 | 179 | | |
194 | 180 | | |
195 | 181 | | |
| |||
220 | 206 | | |
221 | 207 | | |
222 | 208 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 209 | + | |
| 210 | + | |
228 | 211 | | |
229 | 212 | | |
230 | 213 | | |
| |||
243 | 226 | | |
244 | 227 | | |
245 | 228 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
| 229 | + | |
| 230 | + | |
251 | 231 | | |
252 | 232 | | |
253 | 233 | | |
| |||
266 | 246 | | |
267 | 247 | | |
268 | 248 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
| 249 | + | |
| 250 | + | |
274 | 251 | | |
275 | 252 | | |
276 | 253 | | |
| |||
306 | 283 | | |
307 | 284 | | |
308 | 285 | | |
309 | | - | |
310 | | - | |
311 | | - | |
| 286 | + | |
312 | 287 | | |
313 | | - | |
| 288 | + | |
314 | 289 | | |
315 | 290 | | |
316 | 291 | | |
| |||
0 commit comments