Download:
child 114:3585f7847196
parent 112:7eb57ee301b5
113:c572c71bfe3b
Anton Shestakov <av6@dwimlabs.net>, Mon, 25 Jul 2016 16:42:36 +0800
tests: generate both content-type header and json data in json_payload()

1 файлов изменено, 5 вставок(+), 2 удалений(-) [+]
test.py file | annotate | diff | comparison | revisions
--- a/test.py Mon Jul 25 16:24:07 2016 +0800
+++ b/test.py Mon Jul 25 16:42:36 2016 +0800
@@ -26,9 +26,12 @@
item_url = ''
all_url = '/%s/all/'
+ def json_payload(self, data):
+ return {'content_type': 'application/json', 'data': json.dumps(data)}
+
def create_resource(self, new_resource):
url = self.list_url % self.workspace
- response = self.c.post(url, content_type='application/json', data=json.dumps(new_resource))
+ response = self.c.post(url, **self.json_payload(new_resource))
data = json.loads(response.data)
self.assertIn('_t', data)
@@ -66,7 +69,7 @@
def update_resource(self, resource_id, resource_update):
url = self.item_url % (self.workspace, resource_id)
- response = self.c.put(url, content_type='application/json', data=json.dumps(resource_update))
+ response = self.c.put(url, **self.json_payload(resource_update))
data = json.loads(response.data)
self.assertEqual(data['_id'], resource_id)