Added support for requests that return an HTTP 204: No Content. Added tests for creating a private activity and for deleting activities.

This commit is contained in:
ade@google.com
2010-10-11 03:33:51 -07:00
parent b4efbf8811
commit 9d821b0559
2 changed files with 37 additions and 0 deletions

View File

@@ -114,6 +114,9 @@ class JsonModel(object):
# Error handling is TBD, for example, do we retry
# for some operation/error combinations?
if resp.status < 300:
if resp.status == 204:
# A 204: No Content response should be treated differently to all the other success states
return simplejson.loads('{}')
return simplejson.loads(content)['data']
else:
logging.debug('Content from bad request was: %s' % content)

View File

@@ -149,6 +149,23 @@ class BuzzAuthenticatedFunctionalTest(unittest.TestCase):
).execute()
self.assertTrue(activity is not None)
def test_can_create_private_activity(self):
buzz = build('buzz', 'v1', http=self.http)
activity = buzz.activities().insert(userId='@me', body={
'title': 'Testing insert',
'object': {
'content': 'This is a private post.'
},
'visibility': {
'entries': [
{ 'id': 'tag:google.com,2010:buzz-group:108242092577082601423:13' }
]
}
}
).execute()
self.assertTrue(activity is not None)
def test_can_identify_number_of_groups_belonging_to_user(self):
buzz = build('buzz', 'v1', http=self.http)
groups = buzz.groups().list(userId='108242092577082601423').execute()
@@ -208,6 +225,23 @@ class BuzzAuthenticatedFunctionalTest(unittest.TestCase):
group = buzz.groups().get(userId='108242092577082601423', groupId='G:108242092577082601423:9999999').execute()
self.assertEquals(None, group, group)
def test_can_delete_activity(self):
buzz = build('buzz', 'v1', http=self.http)
activity = buzz.activities().insert(userId='@me', body={
'title': 'Activity to be deleted',
'object': {
'content': u'Created this activity so that it can be deleted.',
'type': 'note'}
}
).execute()
id = activity['id']
buzz.activities().delete(scope='@self', userId='@me', postId=id).execute()
activity_url = activity['links']['self'][0]['href']
resp, content = self.http.request(activity_url, 'GET')
self.assertEquals(404, resp.status)
if __name__ == '__main__':
unittest.main()