-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from mozilla-services/add-missing-resources
Add missing resources
- Loading branch information
Showing
11 changed files
with
496 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
from .support import (BaseWebTest, unittest, get_user_headers, | ||
MINIMALIST_BUCKET, MINIMALIST_GROUP, | ||
MINIMALIST_COLLECTION, MINIMALIST_RECORD) | ||
|
||
|
||
class BucketViewTest(BaseWebTest, unittest.TestCase): | ||
|
||
collection_url = '/buckets' | ||
record_url = '/buckets/beers' | ||
|
||
def setUp(self): | ||
super(BucketViewTest, self).setUp() | ||
resp = self.app.put_json(self.record_url, | ||
MINIMALIST_BUCKET, | ||
headers=self.headers) | ||
self.record = resp.json # XXX: ['data'] | ||
|
||
def test_buckets_are_global_to_every_users(self): | ||
self.app.get(self.record_url, headers=get_user_headers('alice')) | ||
|
||
def test_buckets_do_not_support_post(self): | ||
self.app.post(self.collection_url, headers=self.headers, | ||
status=405) | ||
|
||
def test_buckets_can_be_put_with_simple_name(self): | ||
self.assertEqual(self.record['id'], 'beers') | ||
|
||
def test_collection_endpoint_lists_them_all(self): | ||
resp = self.app.get(self.collection_url, headers=self.headers) | ||
records = resp.json['items'] # XXX: ['data'] | ||
self.assertEqual(len(records), 1) | ||
self.assertEqual(records[0]['id'], 'beers') | ||
|
||
def test_buckets_name_should_be_simple(self): | ||
self.app.put_json('/buckets/__beers__', | ||
MINIMALIST_BUCKET, | ||
headers=self.headers, | ||
status=400) | ||
|
||
def test_current_user_receives_write_permission_on_creation(self): | ||
pass | ||
|
||
|
||
class BucketDeletionTest(BaseWebTest, unittest.TestCase): | ||
|
||
bucket_url = '/buckets/beers' | ||
collection_url = '/buckets/beers/collections/barley' | ||
group_url = '/buckets/beers/groups/moderators' | ||
|
||
def setUp(self): | ||
# Create a bucket with some objects. | ||
self.app.put_json(self.bucket_url, MINIMALIST_BUCKET, | ||
headers=self.headers) | ||
self.app.put_json(self.group_url, MINIMALIST_GROUP, | ||
headers=self.headers) | ||
self.app.put_json(self.collection_url, MINIMALIST_COLLECTION, | ||
headers=self.headers) | ||
r = self.app.post_json(self.collection_url + '/records', | ||
MINIMALIST_RECORD, | ||
headers=self.headers) | ||
self.record_url = self.collection_url + '/records/%s' % r.json['id'] | ||
# Delete the bucket. | ||
self.app.delete(self.bucket_url, headers=self.headers) | ||
|
||
def test_buckets_can_be_deleted(self): | ||
self.app.get(self.bucket_url, headers=self.headers, | ||
status=404) | ||
|
||
def test_every_collections_are_deleted_too(self): | ||
self.app.put_json(self.bucket_url, MINIMALIST_BUCKET, | ||
headers=self.headers) | ||
self.app.get(self.collection_url, headers=self.headers, status=404) | ||
|
||
def test_every_groups_are_deleted_too(self): | ||
self.app.put_json(self.bucket_url, MINIMALIST_BUCKET, | ||
headers=self.headers) | ||
self.app.get(self.group_url, headers=self.headers, status=404) | ||
|
||
def test_every_records_are_deleted_too(self): | ||
self.app.put_json(self.bucket_url, MINIMALIST_BUCKET, | ||
headers=self.headers) | ||
self.app.put_json(self.collection_url, MINIMALIST_COLLECTION, | ||
headers=self.headers) | ||
self.app.get(self.record_url, headers=self.headers, status=404) | ||
|
||
def test_permissions_associated_are_deleted_too(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from .support import (BaseWebTest, unittest, MINIMALIST_BUCKET, | ||
MINIMALIST_COLLECTION, MINIMALIST_RECORD) | ||
|
||
|
||
class CollectionViewTest(BaseWebTest, unittest.TestCase): | ||
|
||
collections_url = '/buckets/beers/collections' | ||
collection_url = '/buckets/beers/collections/barley' | ||
|
||
def setUp(self): | ||
super(CollectionViewTest, self).setUp() | ||
self.app.put_json('/buckets/beers', MINIMALIST_BUCKET, | ||
headers=self.headers) | ||
resp = self.app.put_json(self.collection_url, | ||
MINIMALIST_COLLECTION, | ||
headers=self.headers) | ||
self.record = resp.json # XXX: ['data'] | ||
|
||
def test_collection_endpoint_lists_them_all(self): | ||
resp = self.app.get(self.collections_url, headers=self.headers) | ||
records = resp.json['items'] # XXX: ['data'] | ||
self.assertEqual(len(records), 1) | ||
self.assertEqual(records[0]['id'], 'barley') | ||
|
||
def test_collections_do_not_support_post(self): | ||
self.app.post(self.collections_url, headers=self.headers, | ||
status=405) | ||
|
||
def test_collections_can_be_put_with_simple_name(self): | ||
self.assertEqual(self.record['id'], 'barley') | ||
|
||
def test_collections_name_should_be_simple(self): | ||
self.app.put_json('/buckets/beers/collections/__barley__', | ||
MINIMALIST_COLLECTION, | ||
headers=self.headers, | ||
status=400) | ||
|
||
def test_unknown_bucket_raises_404(self): | ||
other_bucket = self.collections_url.replace('beers', 'sodas') | ||
self.app.get(other_bucket, headers=self.headers, status=404) | ||
|
||
def test_collections_are_isolated_by_bucket(self): | ||
other_bucket = self.collection_url.replace('beers', 'water') | ||
self.app.get(other_bucket, headers=self.headers, status=404) | ||
|
||
|
||
class CollectionDeletionTest(BaseWebTest, unittest.TestCase): | ||
|
||
collection_url = '/buckets/beers/collections/barley' | ||
|
||
def setUp(self): | ||
super(CollectionDeletionTest, self).setUp() | ||
self.app.put_json('/buckets/beers', MINIMALIST_BUCKET, | ||
headers=self.headers) | ||
self.app.put_json(self.collection_url, MINIMALIST_COLLECTION, | ||
headers=self.headers) | ||
r = self.app.post_json(self.collection_url + '/records', | ||
MINIMALIST_RECORD, | ||
headers=self.headers) | ||
self.record_url = self.collection_url + '/records/%s' % r.json['id'] | ||
self.app.delete(self.collection_url, headers=self.headers) | ||
|
||
def test_collections_can_be_deleted(self): | ||
self.app.get(self.collection_url, headers=self.headers, | ||
status=404) | ||
|
||
def test_records_of_collection_are_deleted_too(self): | ||
self.app.put_json(self.collection_url, MINIMALIST_COLLECTION, | ||
headers=self.headers) | ||
self.app.get(self.record_url, headers=self.headers, status=404) | ||
|
||
def test_permissions_associated_are_deleted_too(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
from .support import (BaseWebTest, unittest, MINIMALIST_BUCKET, | ||
MINIMALIST_GROUP) | ||
|
||
|
||
class GroupViewTest(BaseWebTest, unittest.TestCase): | ||
|
||
collection_url = '/buckets/beers/groups' | ||
record_url = '/buckets/beers/groups/moderators' | ||
|
||
def setUp(self): | ||
super(GroupViewTest, self).setUp() | ||
self.app.put_json('/buckets/beers', MINIMALIST_BUCKET, | ||
headers=self.headers) | ||
resp = self.app.put_json(self.record_url, | ||
MINIMALIST_GROUP, | ||
headers=self.headers) | ||
self.record = resp.json # XXX: ['data'] | ||
|
||
def test_collection_endpoint_lists_them_all(self): | ||
resp = self.app.get(self.collection_url, headers=self.headers) | ||
records = resp.json['items'] # XXX: ['data'] | ||
self.assertEqual(len(records), 1) | ||
self.assertEqual(records[0]['members'], ['fxa:user']) | ||
|
||
def test_groups_can_be_posted_without_id(self): | ||
resp = self.app.post_json(self.collection_url, | ||
MINIMALIST_GROUP, | ||
headers=self.headers, | ||
status=201) | ||
self.assertIn('id', resp.json) | ||
self.assertEqual(resp.json['members'], ['fxa:user']) | ||
|
||
def test_groups_can_be_put_with_simple_name(self): | ||
self.assertEqual(self.record['id'], 'moderators') | ||
|
||
def test_groups_name_should_be_simple(self): | ||
self.app.put_json('/buckets/beers/groups/__moderator__', | ||
MINIMALIST_GROUP, | ||
headers=self.headers, | ||
status=400) | ||
|
||
def test_unknown_bucket_raises_404(self): | ||
other_bucket = self.collection_url.replace('beers', 'sodas') | ||
self.app.get(other_bucket, headers=self.headers, status=404) | ||
|
||
def test_groups_are_isolated_by_bucket(self): | ||
other_bucket = self.record_url.replace('beers', 'water') | ||
self.app.get(other_bucket, headers=self.headers, status=404) | ||
|
||
|
||
class GroupDeletionTest(BaseWebTest, unittest.TestCase): | ||
|
||
record_url = '/buckets/beers/groups/moderators' | ||
|
||
def setUp(self): | ||
super(GroupDeletionTest, self).setUp() | ||
self.app.put_json('/buckets/beers', MINIMALIST_BUCKET, | ||
headers=self.headers) | ||
|
||
def test_groups_can_be_deleted(self): | ||
self.app.put_json(self.record_url, MINIMALIST_GROUP, | ||
headers=self.headers) | ||
self.app.delete(self.record_url, headers=self.headers) | ||
self.app.get(self.record_url, headers=self.headers, | ||
status=404) | ||
|
||
def test_principal_is_removed_from_users_when_group_deleted(self): | ||
pass | ||
|
||
|
||
class InvalidGroupTest(BaseWebTest, unittest.TestCase): | ||
|
||
record_url = '/buckets/beers/groups/moderators' | ||
|
||
def setUp(self): | ||
super(InvalidGroupTest, self).setUp() | ||
self.app.put_json('/buckets/beers', MINIMALIST_BUCKET, | ||
headers=self.headers) | ||
|
||
def test_groups_must_have_members_attribute(self): | ||
invalid = {} | ||
self.app.put_json(self.record_url, | ||
invalid, | ||
headers=self.headers, | ||
status=400) | ||
|
||
|
||
class GroupPrincipalsTest(BaseWebTest, unittest.TestCase): | ||
|
||
def test_principal_is_added_to_user_when_added_to_members(self): | ||
pass | ||
|
||
def test_principal_is_removed_from_user_when_removed_from_members(self): | ||
pass |
Oops, something went wrong.