How to use the pygsheets.Spreadsheet function in pygsheets

To help you get started, we’ve selected a few pygsheets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nithinmurali / pygsheets / test / offline_tests.py View on Github external
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)
github nithinmurali / pygsheets / test / offline_tests.py View on Github external
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))