Browse Source

fix the test due the change on #6

master
Julio Biason 11 years ago
parent
commit
e91c50a457
  1. 24
      tests/group_tests.py
  2. 24
      tests/users_tests.py

24
tests/group_tests.py

@ -289,9 +289,9 @@ class TestUsersInGroup(LunchoTests):
request = {'usernames': [new_user.username]}
url = '/group/{group_id}/users/'.format(group_id=self.group.id)
rv = self.put(url,
request,
token=self.user.token)
rv = self.post(url,
request,
token=self.user.token)
self.assertJsonOk(rv)
return
@ -307,9 +307,9 @@ class TestUsersInGroup(LunchoTests):
request = {'usernames': [new_user.username]}
url = '/group/{group_id}/users/'.format(group_id=self.group.id)
rv = self.put(url,
request,
token=new_user.token)
rv = self.post(url,
request,
token=new_user.token)
self.assertJsonError(rv, 403, 'User is not admin')
return
@ -317,9 +317,9 @@ class TestUsersInGroup(LunchoTests):
"""Try to add an unknown user to the group."""
request = {'usernames': ['unknown']}
url = '/group/{group_id}/users/'.format(group_id=self.group.id)
rv = self.put(url,
request,
token=self.user.token)
rv = self.post(url,
request,
token=self.user.token)
# not finding users still returns a 200, but with the users in the
# "not_found" field
@ -334,9 +334,9 @@ class TestUsersInGroup(LunchoTests):
# the usernames are worthless, group not found should kick first
request = {'usernames': ['unkonwn']}
group_id = self.group.id + 10
rv = self.put('/group/{group_id}/users/'.format(group_id=group_id),
request,
token=self.user.token)
rv = self.post('/group/{group_id}/users/'.format(group_id=group_id),
request,
token=self.user.token)
self.assertJsonError(rv, 404, 'Group not found')
return

24
tests/users_tests.py

@ -18,7 +18,7 @@ class TestUsers(LunchoTests):
request = {'username': 'username',
'full_name': 'full name',
'password': 'hash'}
rv = self.put('/user/', request)
rv = self.post('/user/', request)
self.assertJsonOk(rv)
# db check
@ -32,7 +32,7 @@ class TestUsers(LunchoTests):
request = {'username': 'username',
'full_name': 'full name',
'password': 'hash'}
rv = self.put('/user/', data=request)
rv = self.post('/user/', data=request)
self.assertJsonError(rv, 409, 'Username already exists')
def test_no_json(self):
@ -43,7 +43,7 @@ class TestUsers(LunchoTests):
def test_missing_fields(self):
"""Send a request with missing fields."""
request = {'password': 'hash'}
rv = self.put('/user/', request)
rv = self.post('/user/', request)
self.assertJsonError(rv, 400, 'Missing fields', fields=['username',
'full_name'])
@ -66,9 +66,9 @@ class TestExistingUsers(LunchoTests):
"""Update user details."""
request = {'full_name': 'New User Name',
'password': 'newhash'}
rv = self.post('/user/',
request,
self.user.token)
rv = self.put('/user/',
request,
self.user.token)
self.assertJsonOk(rv)
@ -81,9 +81,9 @@ class TestExistingUsers(LunchoTests):
"""Send a request with an unexisting token."""
request = {'full_name': 'New User Name',
'password': 'newhash'}
rv = self.post('/user/',
request,
'no-token')
rv = self.put('/user/',
request,
'no-token')
self.assertJsonError(rv, 404, 'User not found (via token)')
@ -96,9 +96,9 @@ class TestExistingUsers(LunchoTests):
request = {'full_name': 'New User Name',
'password': 'newhash'}
rv = self.post('/user/',
request,
self.user.token)
rv = self.put('/user/',
request,
self.user.token)
self.assertJsonError(rv, 400, 'Invalid token')

Loading…
Cancel
Save