def test_getWorksheets(self): key = "TESTKEY" s = self.getSpreadsheet(key, "my_title") # get spreadsheets self.get.return_value.status_code = 200 self.get.return_value.content = get_worksheets_feed( key=key, sheet_names=["sheet_title"]) w = s.getWorksheets() self.checkGetCall( "https://spreadsheets.google.com/feeds/worksheets/{}/private/full". format(key)) self.assertEqual(type(w), list) self.assertEqual(len(w), 1) self.assertEqual(type(w[0]), Worksheet) w = w[0] self.assertEqual(w._getTitle(w._element), "sheet_title") self.assertEqual(w._getSheetKey(), s.getKey()) w = s.getWorksheet('sheet_title') self.assertEqual(type(w), Worksheet) self.assertEqual(w._getTitle(w._element), "sheet_title") self.assertEqual(w._getSheetKey(), s.getKey()) with self.assertRaises(ValueError): s.getWorksheet("fake worksheet")
def test_getWorksheets(self): key = "TESTKEY" s = self.getSpreadsheet(key, "my_title") # get spreadsheets self.get.return_value.status_code = 200 self.get.return_value.content = get_worksheets_feed( key=key, sheet_names=["sheet_title"]) w = s.getWorksheets() self.checkGetCall( "https://spreadsheets.google.com/feeds/worksheets/{}/private/full" .format(key)) self.assertEqual(type(w), list) self.assertEqual(len(w), 1) self.assertEqual(type(w[0]), Worksheet) w = w[0] self.assertEqual(w._getTitle(w._element), "sheet_title") self.assertEqual(w._getSheetKey(), s.getKey()) w = s.getWorksheet('sheet_title') self.assertEqual(type(w), Worksheet) self.assertEqual(w._getTitle(w._element), "sheet_title") self.assertEqual(w._getSheetKey(), s.getKey()) with self.assertRaises(ValueError): s.getWorksheet("fake worksheet")
def test_addRemoveWorksheets(self): key = "TESTKEY" s = self.getSpreadsheet(key, "my_title") # get spreadsheets self.get.return_value.status_code = 200 self.get.return_value.content = get_worksheets_feed( key=key, sheet_names=["sheet_title"]) w = s.getWorksheets() self.checkGetCall( "https://spreadsheets.google.com/feeds/worksheets/{}/private/full". format(key)) self.assertEqual(type(w), list) self.assertEqual(len(w), 1) self.assertEqual(type(w[0]), Worksheet) w = w[0] self.post.return_value.status_code = 201 self.post.return_value.content = get_worksheet_entry( key, "added_sheet_title") w = s.addWorksheet("added_sheet_title") self.checkPostCall( "https://spreadsheets.google.com/feeds/worksheets/{}/private/full". format(key)) self.assertEqual(type(w), Worksheet) self.get.return_value.status_code = 200 self.get.return_value.content = get_worksheet_entry( key, "added_sheet_title") title = w.getTitle() self.checkGetCall( "https://spreadsheets.google.com/feeds/worksheets/{}/private/full/od6" .format(key)) self.assertEqual(title, "added_sheet_title") self.delete.return_value.status_code = 200 self.delete.return_value.content = b'' s.removeWorksheet(w) self.checkDeleteCall( "https://spreadsheets.google.com/feeds/worksheets/{}/private/full/od6/CCCC" .format(key))
def test_addRemoveWorksheets(self): key = "TESTKEY" s = self.getSpreadsheet(key, "my_title") # get spreadsheets self.get.return_value.status_code = 200 self.get.return_value.content = get_worksheets_feed( key=key, sheet_names=["sheet_title"]) w = s.getWorksheets() self.checkGetCall( "https://spreadsheets.google.com/feeds/worksheets/{}/private/full" .format(key)) self.assertEqual(type(w), list) self.assertEqual(len(w), 1) self.assertEqual(type(w[0]), Worksheet) w = w[0] self.post.return_value.status_code = 201 self.post.return_value.content = get_worksheet_entry( key, "added_sheet_title") w = s.addWorksheet("added_sheet_title") self.checkPostCall( "https://spreadsheets.google.com/feeds/worksheets/{}/private/full" .format(key)) self.assertEqual(type(w), Worksheet) self.get.return_value.status_code = 200 self.get.return_value.content = get_worksheet_entry( key, "added_sheet_title") title = w.getTitle() self.checkGetCall( "https://spreadsheets.google.com/feeds/worksheets/{}/private/full/od6" .format(key)) self.assertEqual(title, "added_sheet_title") self.delete.return_value.status_code = 200 self.delete.return_value.content = b'' s.removeWorksheet(w) self.checkDeleteCall( "https://spreadsheets.google.com/feeds/worksheets/{}/private/full/od6/CCCC" .format(key))