From 0101a29ce298a3ceebf57e4edf32f73013f6512f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Fri, 17 Jul 2015 14:30:09 +0200 Subject: [PATCH 1/4] Update test to reflect the optional empty data feature. --- kinto/tests/support.py | 4 ++-- kinto/tests/test_views_buckets.py | 6 ++---- kinto/tests/test_views_groups.py | 15 +++++++++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/kinto/tests/support.py b/kinto/tests/support.py index 0e8220e859..4dd323eb38 100644 --- a/kinto/tests/support.py +++ b/kinto/tests/support.py @@ -10,8 +10,8 @@ from kinto import DEFAULT_SETTINGS -MINIMALIST_BUCKET = {'data': dict()} -MINIMALIST_COLLECTION = {'data': dict()} +MINIMALIST_BUCKET = {} +MINIMALIST_COLLECTION = {} MINIMALIST_GROUP = {'data': dict(members=['fxa:user'])} MINIMALIST_RECORD = {'data': dict(name="Hulled Barley", type="Whole Grain")} diff --git a/kinto/tests/test_views_buckets.py b/kinto/tests/test_views_buckets.py index 802edd05e4..2f3ad18de3 100644 --- a/kinto/tests/test_views_buckets.py +++ b/kinto/tests/test_views_buckets.py @@ -12,16 +12,14 @@ class BucketViewTest(BaseWebTest, unittest.TestCase): def setUp(self): super(BucketViewTest, self).setUp() - bucket = MINIMALIST_BUCKET.copy() resp = self.app.put_json(self.record_url, - bucket, + MINIMALIST_BUCKET, headers=self.headers) self.record = resp.json['data'] def test_buckets_are_global_to_every_users(self): self.app.patch_json(self.record_url, - {'data': {}, - 'permissions': {'read': [Authenticated]}}, + {'permissions': {'read': [Authenticated]}}, headers=self.headers) self.app.get(self.record_url, headers=get_user_headers('alice')) diff --git a/kinto/tests/test_views_groups.py b/kinto/tests/test_views_groups.py index 30f88f0215..c6c0001ee4 100644 --- a/kinto/tests/test_views_groups.py +++ b/kinto/tests/test_views_groups.py @@ -161,7 +161,14 @@ def setUp(self): def test_groups_must_have_members_attribute(self): invalid = {} - self.app.put_json(self.group_url, - invalid, - headers=self.headers, - status=400) + resp = self.app.put_json(self.group_url, + invalid, + headers=self.headers, + status=400) + self.assertEqual(resp.json['message'], + "data.members in body: Required") + self.assertDictEqual(resp.json['details'], { + "description": "Required", + "location": "body", + "name": "data.members" + }) From 3aa8ca3a29aad12a6e12d2d717c3542044a7f467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Fri, 17 Jul 2015 14:38:27 +0200 Subject: [PATCH 2/4] Update the loadtest with the expected behavior. --- loadtests/loadtest/tutorial.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/loadtests/loadtest/tutorial.py b/loadtests/loadtest/tutorial.py index f897f62b74..d5475b8847 100644 --- a/loadtests/loadtest/tutorial.py +++ b/loadtests/loadtest/tutorial.py @@ -139,8 +139,7 @@ def play_user_shared_bucket_tutorial(self): # Create a new bucket and check for permissions resp = self.session.put( - self.bucket_url(bucket_id), - data=json.dumps({'data': {}})) + self.bucket_url(bucket_id)) self.incr_counter("status-%s" % resp.status_code) # We should always have a 201 here. See mozilla-services/cliquet#367 # if resp.status_code == 200: @@ -153,7 +152,7 @@ def play_user_shared_bucket_tutorial(self): permissions = {"record:create": ['system.Authenticated']} resp = self.session.put( re.sub('/records$', '', collection_url), - data=json.dumps({'data': {}, 'permissions': permissions})) + data=json.dumps({'permissions': permissions})) self.incr_counter("status-%s" % resp.status_code) # We should always have a 201 here. See mozilla-services/cliquet#367 # if resp.status_code == 200: @@ -223,7 +222,7 @@ def play_user_shared_bucket_tutorial(self): permissions = {"group:create": ['system.Authenticated']} resp = self.session.put( self.bucket_url(bucket_id), - data=json.dumps({'data': {}, 'permissions': permissions})) + data=json.dumps({'permissions': permissions})) self.incr_counter("status-%s" % resp.status_code) self.assertEqual(resp.status_code, 200) record = resp.json() From 86bbf60f8d8cf5cecce8a60953834a533b112f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Fri, 17 Jul 2015 16:32:00 +0200 Subject: [PATCH 3/4] Fix test. --- kinto/tests/test_views_groups.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kinto/tests/test_views_groups.py b/kinto/tests/test_views_groups.py index c6c0001ee4..2afe4fa776 100644 --- a/kinto/tests/test_views_groups.py +++ b/kinto/tests/test_views_groups.py @@ -166,9 +166,9 @@ def test_groups_must_have_members_attribute(self): headers=self.headers, status=400) self.assertEqual(resp.json['message'], - "data.members in body: Required") - self.assertDictEqual(resp.json['details'], { - "description": "Required", + "data is missing") + self.assertDictEqual(resp.json['details'][0], { + "description": "data is missing", "location": "body", - "name": "data.members" + "name": "data" }) From 96e6cb5a56cae0b0f3297ce5400c88b8778fc9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20HUBSCHER?= Date: Fri, 17 Jul 2015 17:24:32 +0200 Subject: [PATCH 4/4] Investigation --- loadtests/loadtest/tutorial.py | 1 + 1 file changed, 1 insertion(+) diff --git a/loadtests/loadtest/tutorial.py b/loadtests/loadtest/tutorial.py index d5475b8847..2ec9df75f2 100644 --- a/loadtests/loadtest/tutorial.py +++ b/loadtests/loadtest/tutorial.py @@ -146,6 +146,7 @@ def play_user_shared_bucket_tutorial(self): # import pdb; pdb.set_trace() # self.assertEqual(resp.status_code, 201) record = resp.json() + print record self.assertIn('write', record['permissions']) # Create a new collection and check for permissions