diff --git a/functional_tests/test_services.py b/functional_tests/test_services.py index 50a1a4d..a849577 100644 --- a/functional_tests/test_services.py +++ b/functional_tests/test_services.py @@ -19,6 +19,7 @@ import httplib2 import logging import pickle import os +import time import unittest # TODO(ade) Remove this mock once the bug in the discovery document is fixed @@ -227,7 +228,7 @@ class BuzzAuthenticatedFunctionalTest(unittest.TestCase): 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': { @@ -238,6 +239,7 @@ class BuzzAuthenticatedFunctionalTest(unittest.TestCase): id = activity['id'] buzz.activities().delete(scope='@self', userId='@me', postId=id).execute() + time.sleep(2) activity_url = activity['links']['self'][0]['href'] resp, content = self.http.request(activity_url, 'GET') diff --git a/tests/test_json_model.py b/tests/test_json_model.py index 79b63ab..01015f1 100644 --- a/tests/test_json_model.py +++ b/tests/test_json_model.py @@ -65,6 +65,22 @@ class Model(unittest.TestCase): self.assertNotEqual(query, '') self.assertEqual(body, '{"data": {}}') + def test_json_body_default_data(self): + """Test that a 'data' wrapper doesn't get added if one is already present.""" + model = JsonModel() + + headers = {} + path_params = {} + query_params = {} + body = {'data': 'foo'} + + headers, params, query, body = model.request(headers, path_params, query_params, body) + + self.assertEqual(headers['accept'], 'application/json') + self.assertEqual(headers['content-type'], 'application/json') + self.assertNotEqual(query, '') + self.assertEqual(body, '{"data": "foo"}') + def test_json_build_query(self): model = JsonModel()