Is there a way to create mock Spreadsheets and Worksheets without a Google API connection?

27 Views Asked by At

I am trying to write unitary tests regarding some operations we already have with Spreadsheets and Worksheets, however I would like to do so without coupling it to a Google Sheets connection, testing the behaviors in isolation and leaving connection dependent behavior to a future integration tests layer.

Is there a way to do so in gspread? I have seen in the conftest.py (I'm working with the 5.12.4 version, we still haven't updated) file that we should be able to create a client with a DUMMY_ACCESS_TOKEN, though I haven't had any success in making it actually work.

Is this behavior supported and or possible with gspread?

I've tried to create a dummy connection as displayed in conftest.py, to no success. I've also tried to created both Spreadsheet and Worksheet objects without a client (providing null values on initialization), but this is not supported due the fetch_sheet_metadata call on spreadsheet initialization.

I expected it to be possible to create an Worksheet or Spreadsheet object untied to any real object, enabling the testing of behavior in an untied manner to any dependencies.

0

There are 0 best solutions below