|
|
|
@ -36,7 +36,7 @@ class TestGroups(LunchoTests):
|
|
|
|
|
def test_create_group(self): |
|
|
|
|
"""Test creating a group.""" |
|
|
|
|
request = {'name': 'Test group'} |
|
|
|
|
rv = self.put('/group/', |
|
|
|
|
rv = self.post('/group/', |
|
|
|
|
request, |
|
|
|
|
token=self.user.token) |
|
|
|
|
self.assertJsonOk(rv, id=1) |
|
|
|
@ -47,7 +47,7 @@ class TestGroups(LunchoTests):
|
|
|
|
|
server.db.session.commit() |
|
|
|
|
|
|
|
|
|
request = {'name': 'Test group'} |
|
|
|
|
rv = self.put('/group/', |
|
|
|
|
rv = self.post('/group/', |
|
|
|
|
request, |
|
|
|
|
token=self.user.token) |
|
|
|
|
self.assertJsonError(rv, 412, 'Account not verified') |
|
|
|
@ -77,7 +77,7 @@ class TestGroups(LunchoTests):
|
|
|
|
|
def test_create_group_unknown_token(self): |
|
|
|
|
"""Try to create a group with an invalid token.""" |
|
|
|
|
request = {'name': 'Test group'} |
|
|
|
|
rv = self.put('/group/', |
|
|
|
|
rv = self.post('/group/', |
|
|
|
|
request, |
|
|
|
|
token='invalid') |
|
|
|
|
self.assertJsonError(rv, 404, 'User not found (via token)') |
|
|
|
@ -87,7 +87,7 @@ class TestGroups(LunchoTests):
|
|
|
|
|
server.db.session.commit() |
|
|
|
|
|
|
|
|
|
request = {'name': 'Test group'} |
|
|
|
|
rv = self.put('/group/', |
|
|
|
|
rv = self.post('/group/', |
|
|
|
|
request, |
|
|
|
|
token=self.user.token) |
|
|
|
|
self.assertJsonError(rv, 400, 'Invalid token') |
|
|
|
@ -118,7 +118,7 @@ class TestExistingGroups(LunchoTests):
|
|
|
|
|
"""Change the group name.""" |
|
|
|
|
groupId = self.group.id |
|
|
|
|
request = {'name': 'New test group'} |
|
|
|
|
rv = self.post('/group/{groupId}/'.format(groupId=self.group.id), |
|
|
|
|
rv = self.put('/group/{groupId}/'.format(groupId=self.group.id), |
|
|
|
|
request, |
|
|
|
|
token=self.user.token) |
|
|
|
|
self.assertJsonOk(rv) |
|
|
|
@ -130,7 +130,7 @@ class TestExistingGroups(LunchoTests):
|
|
|
|
|
def test_update_name_invalid_token(self): |
|
|
|
|
"""Try to change the name with an unknown token.""" |
|
|
|
|
request = {'name': 'New test group'} |
|
|
|
|
rv = self.post('/group/{groupId}/'.format(groupId=self.group.id), |
|
|
|
|
rv = self.put('/group/{groupId}/'.format(groupId=self.group.id), |
|
|
|
|
request, |
|
|
|
|
token='invalid') |
|
|
|
|
self.assertJsonError(rv, 404, 'User not found (via token)') |
|
|
|
@ -141,7 +141,7 @@ class TestExistingGroups(LunchoTests):
|
|
|
|
|
server.db.session.commit() |
|
|
|
|
|
|
|
|
|
request = {'name': 'New test group'} |
|
|
|
|
rv = self.post('/group/{groupId}/'.format(groupId=self.group.id), |
|
|
|
|
rv = self.put('/group/{groupId}/'.format(groupId=self.group.id), |
|
|
|
|
request, |
|
|
|
|
token=self.user.token) |
|
|
|
|
self.assertJsonError(rv, 400, 'Invalid token') |
|
|
|
@ -158,7 +158,7 @@ class TestExistingGroups(LunchoTests):
|
|
|
|
|
new_username = new_user.username |
|
|
|
|
|
|
|
|
|
request = {'admin': new_user.username} |
|
|
|
|
rv = self.post('/group/{groupId}/'.format(groupId=groupId), |
|
|
|
|
rv = self.put('/group/{groupId}/'.format(groupId=groupId), |
|
|
|
|
request, |
|
|
|
|
token=self.user.token) |
|
|
|
|
self.assertJsonOk(rv) |
|
|
|
@ -170,7 +170,7 @@ class TestExistingGroups(LunchoTests):
|
|
|
|
|
def test_update_owner_invalid(self): |
|
|
|
|
"""Try to change the owner to a user that doesn't exist.""" |
|
|
|
|
request = {'admin': 'unknown'} |
|
|
|
|
rv = self.post('/group/{groupId}/'.format(groupId=self.group.id), |
|
|
|
|
rv = self.put('/group/{groupId}/'.format(groupId=self.group.id), |
|
|
|
|
request, |
|
|
|
|
token=self.user.token) |
|
|
|
|
self.assertJsonError(rv, 404, 'New admin not found') |
|
|
|
@ -179,7 +179,7 @@ class TestExistingGroups(LunchoTests):
|
|
|
|
|
"""Try to update a group that doesn't exist.""" |
|
|
|
|
groupId = self.group.id + 10 |
|
|
|
|
request = {'name': 'New test group'} |
|
|
|
|
rv = self.post('/group/{groupId}/'.format(groupId=groupId), |
|
|
|
|
rv = self.put('/group/{groupId}/'.format(groupId=groupId), |
|
|
|
|
request, |
|
|
|
|
token=self.user.token) |
|
|
|
|
self.assertJsonError(rv, 404, 'Group not found') |
|
|
|
@ -283,8 +283,8 @@ class TestUsersInGroup(LunchoTests):
|
|
|
|
|
|
|
|
|
|
def test_add_unknown_group(self): |
|
|
|
|
"""Try to add users to some unknown group.""" |
|
|
|
|
request = {'usernames': ['unkonwn']} # group not found should |
|
|
|
|
# kick first |
|
|
|
|
# the usernames are worthless, group not found should kick first |
|
|
|
|
request = {'usernames': ['unkonwn']} |
|
|
|
|
groupId = self.group.id + 10 |
|
|
|
|
rv = self.put('/group/{groupId}/users/'.format(groupId=groupId), |
|
|
|
|
request, |
|
|
|
|