Skip to content

Commit 8963ff9

Browse files
committed
Added test of new model where 'data' wrapper isn't added if it isn't necessary. This will allow developers to cut and paste JSON from the developer docs into Python code and it should just work.
1 parent 4fb70cc commit 8963ff9

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

functional_tests/test_services.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import logging
2020
import pickle
2121
import os
22+
import time
2223
import unittest
2324

2425
# TODO(ade) Remove this mock once the bug in the discovery document is fixed
@@ -227,7 +228,7 @@ def IGNORE__test_can_list_groups_belonging_to_user(self):
227228

228229
def test_can_delete_activity(self):
229230
buzz = build('buzz', 'v1', http=self.http)
230-
231+
231232
activity = buzz.activities().insert(userId='@me', body={
232233
'title': 'Activity to be deleted',
233234
'object': {
@@ -238,6 +239,7 @@ def test_can_delete_activity(self):
238239
id = activity['id']
239240

240241
buzz.activities().delete(scope='@self', userId='@me', postId=id).execute()
242+
time.sleep(2)
241243

242244
activity_url = activity['links']['self'][0]['href']
243245
resp, content = self.http.request(activity_url, 'GET')

tests/test_json_model.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ def test_json_body(self):
6565
self.assertNotEqual(query, '')
6666
self.assertEqual(body, '{"data": {}}')
6767

68+
def test_json_body_default_data(self):
69+
"""Test that a 'data' wrapper doesn't get added if one is already present."""
70+
model = JsonModel()
71+
72+
headers = {}
73+
path_params = {}
74+
query_params = {}
75+
body = {'data': 'foo'}
76+
77+
headers, params, query, body = model.request(headers, path_params, query_params, body)
78+
79+
self.assertEqual(headers['accept'], 'application/json')
80+
self.assertEqual(headers['content-type'], 'application/json')
81+
self.assertNotEqual(query, '')
82+
self.assertEqual(body, '{"data": "foo"}')
83+
6884
def test_json_build_query(self):
6985
model = JsonModel()
7086

0 commit comments

Comments
 (0)