Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If data is not provided, then don't raise a missing but default to empty. #63

Merged
merged 4 commits into from
Aug 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kinto/tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")}
Expand Down
6 changes: 2 additions & 4 deletions kinto/tests/test_views_buckets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand Down
15 changes: 11 additions & 4 deletions kinto/tests/test_views_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 is missing")
self.assertDictEqual(resp.json['details'][0], {
"description": "data is missing",
"location": "body",
"name": "data"
})
11 changes: 4 additions & 7 deletions loadtests/loadtest/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ def play_user_default_bucket_tutorial(self):
self.incr_counter("status-%s" % resp.status_code)
self.assertEqual(resp.status_code, 200)
record = resp.json()['data']
# XXX: Should be the ETag header see mozilla-services/cliquet#352
etag = '"%s"' % record['last_modified']
etag = resp.headers['ETag']

# Delete the record with If-Match
resp = self.session.delete(
Expand Down Expand Up @@ -139,8 +138,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:
Expand All @@ -153,7 +151,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:
Expand Down Expand Up @@ -188,7 +186,6 @@ def play_user_shared_bucket_tutorial(self):
self.assertEqual(resp.status_code, 201)
record = resp.json()
self.assertIn('write', record['permissions'])
# bob_task_id = record['data']['id']
bob_user_id = record['permissions']['write'][0]

# Share Alice's task with Bob
Expand Down Expand Up @@ -223,7 +220,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()
Expand Down