Browse Source

conversion from put to post (and vice versa)

master
Julio Biason 11 years ago
parent
commit
dceff90e89
  1. 64
      tests/group_tests.py

64
tests/group_tests.py

@ -36,9 +36,9 @@ 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)
def test_create_group_unverified_account(self): def test_create_group_unverified_account(self):
@ -47,9 +47,9 @@ 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')
def test_user_in_own_group(self): def test_user_in_own_group(self):
@ -77,9 +77,9 @@ 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)')
def test_create_group_expired_token(self): def test_create_group_expired_token(self):
@ -87,9 +87,9 @@ 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,9 +118,9 @@ 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)
# check the database # check the database
@ -130,9 +130,9 @@ 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)')
def test_update_name_expired_token(self): def test_update_name_expired_token(self):
@ -141,9 +141,9 @@ 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')
def test_update_owner(self): def test_update_owner(self):
@ -158,9 +158,9 @@ 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)
# check the database # check the database
@ -170,18 +170,18 @@ 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')
def test_update_unknown_group(self): def test_update_unknown_group(self):
"""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')
def test_delete_group(self): def test_delete_group(self):
@ -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,

Loading…
Cancel
Save