Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
with open('spreadsheet.json') as data_file:
spreadsheet_json = json.load(data_file)
with open('worksheet.json') as data_file:
worksheet_json = json.load(data_file)
spreadsheet_json["Sheets"].append(worksheet_json)
cls.config = read_config(CONFIG_FILENAME)
# cls.gc = mock.create_autospec(pygsheets.Client)
# cls.gc.open_by_key.return_value = spreadsheet_json
# cls.gc._fetch_sheets = [{'testssheetid': 'testssheettitle'}]
# cls.spreadsheet = pygsheets.Spreadsheet(cls.gc)
cls.gc.service.spreadsheets().get = mock.create_autospec(cls.gc.service.spreadsheets().get)
cls.gc.open_by_key.return_value = spreadsheet_json
cls.gc._fetch_sheets = [{'testssheetid': 'testssheettitle'}]
cls.spreadsheet = pygsheets.Spreadsheet(cls.gc)
def test_open(self, mock_get):
mock_response = mock.Mock()
mock_response.execute.return_value = self.spreadsheet
mock_get.return_value = mock_response
spreadsheet = self.gc.open('testssheettitle')
mock_get.assert_called_once_with(spreadsheetId=self.config.get('Spreadsheet', 'key'),
fields='properties,sheets/properties,spreadsheetId')
assert(isinstance(spreadsheet, pygsheets.Spreadsheet))