From c11bec638a30beaf1f2dd6444f26187534d2300c Mon Sep 17 00:00:00 2001 From: Joe Gregorio Date: Mon, 6 Jun 2011 09:43:00 -0400 Subject: [PATCH] Add functional tests for patch and fields. Reviewed in http://codereview.appspot.com/4536109/ --- functional_tests/test_services.py | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/functional_tests/test_services.py b/functional_tests/test_services.py index 205cab1..f9263a3 100644 --- a/functional_tests/test_services.py +++ b/functional_tests/test_services.py @@ -142,6 +142,45 @@ class BuzzAuthenticatedFunctionalTest(unittest.TestCase): ).execute() self.assertTrue(activity is not None) + def test_fields_parameter_restricts_response_fields(self): + activity = self.buzz.activities().insert(userId='@me', body={ + 'data': { + 'title': 'Testing patch', + 'object': { + 'content': u'Just a short note to show that insert is working. ?', + 'type': 'note'} + } + } + ).execute() + self.assertTrue('kind' in activity) + + # test fields to restrict what is returned + activity = self.buzz.activities().get(userId='@me', postId=activity['id'], + fields='object,id').execute() + self.assertTrue('kind' not in activity) + self.assertTrue('object' in activity) + self.assertTrue('id' in activity) + + def test_patch(self): + activity = self.buzz.activities().insert(userId='@me', body={ + 'data': { + 'title': 'Testing patch', + 'object': { + 'content': u'Just a short note to show that insert is working. ?', + 'type': 'note'} + } + }).execute() + # Construct a raw patch to send, also restrict the response with fields + activity = self.buzz.activities().patch(userId='@me', + scope='@self', + postId=activity['id'], + body={ + 'object': { + 'content': 'Updated content only!'}}, + fields='object').execute() + self.assertEquals(activity['object']['content'], 'Updated content only!') + self.assertTrue('id' not in activity) + def test_can_create_private_activity(self): activity = self.buzz.activities().insert(userId='@me', body={ 'data': {