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