ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 1 | #!/usr/bin/python2.4 |
| 2 | # |
| 3 | # Copyright 2010 Google Inc. All Rights Reserved. |
| 4 | |
| 5 | """Discovery document tests |
| 6 | |
| 7 | Functional tests that verify we can retrieve data from existing services. |
ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 8 | """ |
| 9 | |
| 10 | __author__ = 'ade@google.com (Ade Oshineye)' |
| 11 | |
ade@google.com | a9907a2 | 2010-12-11 02:44:37 +0000 | [diff] [blame] | 12 | import httplib2 |
| 13 | import pprint |
| 14 | |
ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 15 | from apiclient.discovery import build |
ade@google.com | 2ab0de7 | 2010-09-27 23:26:54 +0100 | [diff] [blame] | 16 | import httplib2 |
ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 17 | import logging |
ade@google.com | 6a05e7d | 2010-10-05 00:29:51 -0700 | [diff] [blame] | 18 | import pickle |
ade@google.com | 2ab0de7 | 2010-09-27 23:26:54 +0100 | [diff] [blame] | 19 | import os |
Joe Gregorio | 8963ff9 | 2010-10-11 13:14:43 -0400 | [diff] [blame] | 20 | import time |
ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 21 | import unittest |
| 22 | |
ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 23 | class BuzzFunctionalTest(unittest.TestCase): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 24 | def setUp(self): |
| 25 | self.buzz = build('buzz', 'v1', developerKey='AIzaSyD7aEm5tyC9BAdoC-MfL0ol7VV1P4zQgig') |
| 26 | |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 27 | def test_can_get_specific_activity(self): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 28 | activity = self.buzz.activities().get(userId='105037104815911535953', |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 29 | postId='B:z12sspviqyakfvye123wehng0muwz5jzq04').execute() |
| 30 | |
| 31 | self.assertTrue(activity is not None) |
| 32 | |
| 33 | def test_can_get_specific_activity_with_tag_id(self): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 34 | activity = self.buzz.activities().get(userId='105037104815911535953', |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 35 | postId='tag:google.com,2010:buzz:z13ptnw5usmnv15ey22fzlswnuqoebasu').execute() |
| 36 | |
| 37 | self.assertTrue(activity is not None) |
| 38 | |
ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 39 | def test_can_get_buzz_activities_with_many_params(self): |
ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 40 | max_results = 2 |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 41 | activities_command = self.buzz.activities() |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 42 | activities = activities_command.list(userId='googlebuzz', scope='@self', |
Joe Gregorio | c5c5a37 | 2010-09-22 11:42:32 -0400 | [diff] [blame] | 43 | max_comments=max_results*2 ,max_liked=max_results*3, |
Joe Gregorio | db849af | 2010-09-22 16:53:59 -0400 | [diff] [blame] | 44 | max_results=max_results).execute() |
| 45 | activity_count = len(activities['items']) |
ade@google.com | 46179d3 | 2010-08-21 00:00:03 +0100 | [diff] [blame] | 46 | self.assertEquals(max_results, activity_count) |
Joe Gregorio | c5c5a37 | 2010-09-22 11:42:32 -0400 | [diff] [blame] | 47 | |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 48 | activities = activities_command.list_next(activities).execute() |
Joe Gregorio | db849af | 2010-09-22 16:53:59 -0400 | [diff] [blame] | 49 | activity_count = len(activities['items']) |
| 50 | self.assertEquals(max_results, activity_count) |
| 51 | |
ade@google.com | 2ab0de7 | 2010-09-27 23:26:54 +0100 | [diff] [blame] | 52 | def test_can_get_multiple_pages_of_buzz_activities(self): |
ade@google.com | 973d1a6 | 2010-09-23 21:21:21 +0100 | [diff] [blame] | 53 | max_results = 2 |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 54 | activities_command = self.buzz.activities() |
Joe Gregorio | c935907 | 2010-10-25 15:26:13 -0400 | [diff] [blame] | 55 | |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 56 | activities = activities_command.list(userId='adewale', scope='@self', |
ade@google.com | 973d1a6 | 2010-09-23 21:21:21 +0100 | [diff] [blame] | 57 | max_results=max_results).execute() |
| 58 | for count in range(10): |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 59 | activities = activities_command.list_next(activities).execute() |
ade@google.com | 973d1a6 | 2010-09-23 21:21:21 +0100 | [diff] [blame] | 60 | activity_count = len(activities['items']) |
| 61 | self.assertEquals(max_results, activity_count, 'Failed after %s pages' % str(count)) |
| 62 | |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 63 | def IGNORE_test_can_get_multiple_pages_of_buzz_likers(self): |
ade@google.com | 2ab0de7 | 2010-09-27 23:26:54 +0100 | [diff] [blame] | 64 | # Ignore this test until the Buzz API fixes the bug with next links |
| 65 | # http://code.google.com/p/google-buzz-api/issues/detail?id=114 |
ade@google.com | 2ab0de7 | 2010-09-27 23:26:54 +0100 | [diff] [blame] | 66 | max_results = 1 |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 67 | people_cmd = self.buzz.people() |
ade@google.com | f21095c | 2010-12-10 20:44:13 +0000 | [diff] [blame] | 68 | # The post https://www.googleapis.com/buzz/v1/activities/111062888259659218284/@self/B:z13nh535yk2syfob004cdjyb3mjeulcwv3c?alt=json# |
| 69 | #Perform this call https://www.googleapis.com/buzz/v1/activities/111062888259659218284/@self/B:z13nh535yk2syfob004cdjyb3mjeulcwv3c/@liked?alt=json&max-results=1 |
ade@google.com | 2ab0de7 | 2010-09-27 23:26:54 +0100 | [diff] [blame] | 70 | people = people_cmd.liked(groupId='@liked', userId='googlebuzz', scope='@self', |
| 71 | postId='B:z13nh535yk2syfob004cdjyb3mjeulcwv3c', max_results=max_results).execute() |
| 72 | |
| 73 | for count in range(10): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 74 | print count |
ade@google.com | 2ab0de7 | 2010-09-27 23:26:54 +0100 | [diff] [blame] | 75 | people = people_cmd.liked_next(people).execute() |
| 76 | people_count = len(people['items']) |
| 77 | self.assertEquals(max_results, people_count, 'Failed after %s pages' % str(count)) |
| 78 | |
ade@google.com | d6d6f2f | 2010-09-28 07:37:25 +0100 | [diff] [blame] | 79 | def test_can_get_user_profile(self): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 80 | person = self.buzz.people().get(userId='googlebuzz').execute() |
ade@google.com | d6d6f2f | 2010-09-28 07:37:25 +0100 | [diff] [blame] | 81 | |
| 82 | self.assertTrue(person is not None) |
| 83 | self.assertEquals('buzz#person', person['kind']) |
| 84 | self.assertEquals('Google Buzz Team', person['displayName']) |
| 85 | self.assertEquals('111062888259659218284', person['id']) |
ade@google.com | 1407107 | 2011-03-13 00:46:21 +0000 | [diff] [blame] | 86 | self.assertEquals('https://profiles.google.com/googlebuzz', person['profileUrl']) |
ade@google.com | d6d6f2f | 2010-09-28 07:37:25 +0100 | [diff] [blame] | 87 | |
ade@google.com | 5185853 | 2010-10-14 12:09:22 -0500 | [diff] [blame] | 88 | def test_can_get_user_profile_using_numeric_identifier(self): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 89 | person = self.buzz.people().get(userId='108242092577082601423').execute() |
ade@google.com | 5185853 | 2010-10-14 12:09:22 -0500 | [diff] [blame] | 90 | |
| 91 | self.assertTrue(person is not None) |
| 92 | self.assertEquals('buzz#person', person['kind']) |
| 93 | self.assertEquals('Test Account', person['displayName']) |
| 94 | self.assertEquals('108242092577082601423', person['id']) |
ade@google.com | 1407107 | 2011-03-13 00:46:21 +0000 | [diff] [blame] | 95 | self.assertEquals('https://profiles.google.com/108242092577082601423', person['profileUrl']) |
ade@google.com | 5185853 | 2010-10-14 12:09:22 -0500 | [diff] [blame] | 96 | |
ade@google.com | 567ee8d | 2010-10-06 06:13:18 -0700 | [diff] [blame] | 97 | def test_can_get_followees_of_user(self): |
ade@google.com | 567ee8d | 2010-10-06 06:13:18 -0700 | [diff] [blame] | 98 | expected_followees = 30 |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 99 | following = self.buzz.people().list(userId='googlebuzz', groupId='@following', max_results=expected_followees).execute() |
ade@google.com | 567ee8d | 2010-10-06 06:13:18 -0700 | [diff] [blame] | 100 | |
| 101 | self.assertEquals(expected_followees, following['totalResults']) |
| 102 | self.assertEquals(expected_followees, len(following['entry'])) |
| 103 | |
| 104 | def test_can_efficiently_get_follower_count_of_user(self): |
ade@google.com | 567ee8d | 2010-10-06 06:13:18 -0700 | [diff] [blame] | 105 | |
| 106 | # Restricting max_results to 1 means only a tiny amount of data comes back but the totalResults still has the total. |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 107 | followers = self.buzz.people().list(userId='googlebuzz', groupId='@followers', |
Joe Gregorio | bc2ff9b | 2010-11-08 09:20:48 -0500 | [diff] [blame] | 108 | max_results='1').execute() |
ade@google.com | 567ee8d | 2010-10-06 06:13:18 -0700 | [diff] [blame] | 109 | |
| 110 | # @googlebuzz has a large but fluctuating number of followers |
| 111 | # It is sufficient if the result is bigger than 10, 000 |
ade@google.com | e45ea6c | 2011-01-11 18:15:57 +0000 | [diff] [blame] | 112 | follower_count = followers['totalResults'] |
ade@google.com | 567ee8d | 2010-10-06 06:13:18 -0700 | [diff] [blame] | 113 | self.assertTrue(follower_count > 10000, follower_count) |
| 114 | |
ade@google.com | d9427cf | 2011-01-03 19:18:44 +0000 | [diff] [blame] | 115 | def test_follower_count_is_missing_for_user_with_hidden_follower_count(self): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 116 | followers = self.buzz.people().list(userId='adewale', groupId='@followers').execute() |
Joe Gregorio | c935907 | 2010-10-25 15:26:13 -0400 | [diff] [blame] | 117 | |
ade@google.com | e45ea6c | 2011-01-11 18:15:57 +0000 | [diff] [blame] | 118 | self.assertFalse('totalResults' in followers) |
ade@google.com | 567ee8d | 2010-10-06 06:13:18 -0700 | [diff] [blame] | 119 | |
ade@google.com | 75fdddd | 2010-09-29 16:44:00 +0100 | [diff] [blame] | 120 | |
| 121 | class BuzzAuthenticatedFunctionalTest(unittest.TestCase): |
ade@google.com | 6a05e7d | 2010-10-05 00:29:51 -0700 | [diff] [blame] | 122 | def __init__(self, method_name): |
| 123 | unittest.TestCase.__init__(self, method_name) |
| 124 | credentials_dir = os.path.join(logging.os.path.dirname(__file__), './data') |
| 125 | f = file(os.path.join(credentials_dir, 'buzz_credentials.dat'), 'r') |
| 126 | credentials = pickle.loads(f.read()) |
| 127 | f.close() |
ade@google.com | 75fdddd | 2010-09-29 16:44:00 +0100 | [diff] [blame] | 128 | |
ade@google.com | 6a05e7d | 2010-10-05 00:29:51 -0700 | [diff] [blame] | 129 | self.http = credentials.authorize(httplib2.Http()) |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 130 | self.buzz = build('buzz', 'v1', http=self.http, developerKey='AIzaSyD7aEm5tyC9BAdoC-MfL0ol7VV1P4zQgig') |
ade@google.com | 6a05e7d | 2010-10-05 00:29:51 -0700 | [diff] [blame] | 131 | |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 132 | def test_can_create_activity(self): |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 133 | |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 134 | activity = self.buzz.activities().insert(userId='@me', body={ |
Joe Gregorio | bc2ff9b | 2010-11-08 09:20:48 -0500 | [diff] [blame] | 135 | 'data': { |
| 136 | 'title': 'Testing insert', |
| 137 | 'object': { |
| 138 | 'content': u'Just a short note to show that insert is working. ?', |
| 139 | 'type': 'note'} |
| 140 | } |
| 141 | } |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 142 | ).execute() |
| 143 | self.assertTrue(activity is not None) |
| 144 | |
Joe Gregorio | c11bec6 | 2011-06-06 09:43:00 -0400 | [diff] [blame] | 145 | def test_fields_parameter_restricts_response_fields(self): |
| 146 | activity = self.buzz.activities().insert(userId='@me', body={ |
| 147 | 'data': { |
| 148 | 'title': 'Testing patch', |
| 149 | 'object': { |
| 150 | 'content': u'Just a short note to show that insert is working. ?', |
| 151 | 'type': 'note'} |
| 152 | } |
| 153 | } |
| 154 | ).execute() |
| 155 | self.assertTrue('kind' in activity) |
| 156 | |
| 157 | # test fields to restrict what is returned |
| 158 | activity = self.buzz.activities().get(userId='@me', postId=activity['id'], |
| 159 | fields='object,id').execute() |
| 160 | self.assertTrue('kind' not in activity) |
| 161 | self.assertTrue('object' in activity) |
| 162 | self.assertTrue('id' in activity) |
| 163 | |
| 164 | def test_patch(self): |
| 165 | activity = self.buzz.activities().insert(userId='@me', body={ |
| 166 | 'data': { |
| 167 | 'title': 'Testing patch', |
| 168 | 'object': { |
| 169 | 'content': u'Just a short note to show that insert is working. ?', |
| 170 | 'type': 'note'} |
| 171 | } |
| 172 | }).execute() |
| 173 | # Construct a raw patch to send, also restrict the response with fields |
| 174 | activity = self.buzz.activities().patch(userId='@me', |
| 175 | scope='@self', |
| 176 | postId=activity['id'], |
| 177 | body={ |
| 178 | 'object': { |
| 179 | 'content': 'Updated content only!'}}, |
| 180 | fields='object').execute() |
| 181 | self.assertEquals(activity['object']['content'], 'Updated content only!') |
| 182 | self.assertTrue('id' not in activity) |
| 183 | |
ade@google.com | 9d821b0 | 2010-10-11 03:33:51 -0700 | [diff] [blame] | 184 | def test_can_create_private_activity(self): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 185 | activity = self.buzz.activities().insert(userId='@me', body={ |
Joe Gregorio | bc2ff9b | 2010-11-08 09:20:48 -0500 | [diff] [blame] | 186 | 'data': { |
| 187 | 'title': 'Testing insert', |
| 188 | 'object': { |
| 189 | 'content': 'This is a private post.' |
| 190 | }, |
| 191 | 'visibility': { |
| 192 | 'entries': [ |
| 193 | { 'id': 'tag:google.com,2010:buzz-group:108242092577082601423:13' } |
| 194 | ] |
| 195 | } |
| 196 | } |
| 197 | } |
ade@google.com | 9d821b0 | 2010-10-11 03:33:51 -0700 | [diff] [blame] | 198 | ).execute() |
| 199 | self.assertTrue(activity is not None) |
| 200 | |
ade@google.com | 41b2603 | 2010-10-20 17:37:18 -0700 | [diff] [blame] | 201 | def test_can_create_and_delete_new_group(self): |
ade@google.com | 41b2603 | 2010-10-20 17:37:18 -0700 | [diff] [blame] | 202 | group_name = 'New Group Created At' + str(time.time()) |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 203 | group = self.buzz.groups().insert(userId='@me', body = { |
ade@google.com | 41b2603 | 2010-10-20 17:37:18 -0700 | [diff] [blame] | 204 | 'data': { |
| 205 | 'title': group_name |
| 206 | } |
| 207 | }).execute() |
| 208 | self.assertTrue(group is not None) |
| 209 | |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 210 | result = self.buzz.groups().delete(userId='@me', groupId=group['id']).execute() |
ade@google.com | 41b2603 | 2010-10-20 17:37:18 -0700 | [diff] [blame] | 211 | self.assertEquals({}, result) |
| 212 | |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 213 | def test_can_identify_number_of_groups_belonging_to_user(self): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 214 | groups = self.buzz.groups().list(userId='108242092577082601423').execute() |
ade@google.com | 6a05e7d | 2010-10-05 00:29:51 -0700 | [diff] [blame] | 215 | |
ade@google.com | 41b2603 | 2010-10-20 17:37:18 -0700 | [diff] [blame] | 216 | # This should work as long as no-one deletes the 4 default groups for this test account |
ade@google.com | 6a05e7d | 2010-10-05 00:29:51 -0700 | [diff] [blame] | 217 | expected_default_number_of_groups = 4 |
ade@google.com | 41b2603 | 2010-10-20 17:37:18 -0700 | [diff] [blame] | 218 | self.assertTrue(len(groups['items']) > expected_default_number_of_groups) |
ade@google.com | 75fdddd | 2010-09-29 16:44:00 +0100 | [diff] [blame] | 219 | |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 220 | def IGNORE__test_can_like_activity(self): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 221 | activity = self.buzz.activities().insert(userId='@me', body={ |
Joe Gregorio | bc2ff9b | 2010-11-08 09:20:48 -0500 | [diff] [blame] | 222 | 'data': { |
| 223 | 'title': 'Testing insert', |
| 224 | 'object': { |
| 225 | 'content': u'Just a short note to show that insert is working. ?', |
| 226 | 'type': 'note'} |
| 227 | } |
| 228 | } |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 229 | ).execute() |
| 230 | pprint.pprint(activity) |
| 231 | id = activity['id'] |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 232 | likers = self.buzz.people().liked(userId='105037104815911535953', postId=id, groupId='@liked', scope='@self').execute() |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 233 | # Todo(ade) Insert the new liker once the Buzz back-end bug is fixed |
| 234 | |
| 235 | def test_can_comment_on_activity(self): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 236 | activity = self.buzz.activities().insert(userId='@me', body={ |
Joe Gregorio | bc2ff9b | 2010-11-08 09:20:48 -0500 | [diff] [blame] | 237 | 'data': { |
| 238 | 'title': 'A new activity', |
| 239 | 'object': { |
| 240 | 'content': u'The body of the new activity', |
| 241 | 'type': 'note'} |
| 242 | } |
| 243 | } |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 244 | ).execute() |
| 245 | |
| 246 | id = activity['id'] |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 247 | comment = self.buzz.comments().insert(userId='@me', postId=id, body={ |
Joe Gregorio | bc2ff9b | 2010-11-08 09:20:48 -0500 | [diff] [blame] | 248 | 'data': { |
| 249 | 'content': 'A comment on the new activity' |
| 250 | } |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 251 | }).execute() |
| 252 | |
ade@google.com | c36ac53 | 2010-10-25 15:22:50 -0400 | [diff] [blame] | 253 | def test_can_list_groups_belonging_to_user(self): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 254 | groups = self.buzz.groups().list(userId='108242092577082601423').execute() |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 255 | |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 256 | group = self.buzz.groups().get(userId='108242092577082601423', groupId='G:108242092577082601423:15').execute() |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 257 | self.assertEquals('G:108242092577082601423:15', group['id'], group) |
| 258 | |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 259 | group = self.buzz.groups().get(userId='108242092577082601423', groupId='G:108242092577082601423:14').execute() |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 260 | self.assertEquals('G:108242092577082601423:14', group['id'], group) |
| 261 | |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 262 | group = self.buzz.groups().get(userId='108242092577082601423', groupId='G:108242092577082601423:13').execute() |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 263 | self.assertEquals('G:108242092577082601423:13', group['id'], group) |
| 264 | |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 265 | group = self.buzz.groups().get(userId='108242092577082601423', groupId='G:108242092577082601423:6').execute() |
ade@google.com | 4f2794e | 2010-10-11 02:11:48 -0700 | [diff] [blame] | 266 | self.assertEquals('G:108242092577082601423:6', group['id'], group) |
| 267 | |
ade@google.com | 9d821b0 | 2010-10-11 03:33:51 -0700 | [diff] [blame] | 268 | def test_can_delete_activity(self): |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 269 | activity = self.buzz.activities().insert(userId='@me', body={ |
Joe Gregorio | bc2ff9b | 2010-11-08 09:20:48 -0500 | [diff] [blame] | 270 | 'data': { |
| 271 | 'title': 'Activity to be deleted', |
| 272 | 'object': { |
| 273 | 'content': u'Created this activity so that it can be deleted.', |
| 274 | 'type': 'note'} |
| 275 | } |
| 276 | } |
ade@google.com | 9d821b0 | 2010-10-11 03:33:51 -0700 | [diff] [blame] | 277 | ).execute() |
| 278 | id = activity['id'] |
| 279 | |
Joe Gregorio | b696467 | 2011-05-26 22:02:23 -0400 | [diff] [blame] | 280 | self.buzz.activities().delete(scope='@self', userId='@me', postId=id).execute() |
Joe Gregorio | 8963ff9 | 2010-10-11 13:14:43 -0400 | [diff] [blame] | 281 | time.sleep(2) |
ade@google.com | 9d821b0 | 2010-10-11 03:33:51 -0700 | [diff] [blame] | 282 | |
| 283 | activity_url = activity['links']['self'][0]['href'] |
| 284 | resp, content = self.http.request(activity_url, 'GET') |
| 285 | self.assertEquals(404, resp.status) |
ade@google.com | 75fdddd | 2010-09-29 16:44:00 +0100 | [diff] [blame] | 286 | |
Joe Gregorio | db849af | 2010-09-22 16:53:59 -0400 | [diff] [blame] | 287 | if __name__ == '__main__': |
| 288 | unittest.main() |