Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
Signed-off-by: Dennis Wambua <[email protected]>
  • Loading branch information
denniswambua committed Feb 1, 2017
1 parent 9d5ca36 commit fbdc902
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions onadata/apps/api/tests/viewsets/test_user_profile_viewset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import json
import requests

from mock import patch
from django_digest.test import DigestAuth


from httmock import all_requests, HTTMock

from onadata.apps.api.tests.viewsets.test_abstract_viewset import\
TestAbstractViewSet
from onadata.apps.api.viewsets.user_profile_viewset import UserProfileViewSet
Expand Down Expand Up @@ -764,3 +768,24 @@ def test_profile_create_fails_with_long_first_and_last_names(self):
self.assertEqual(response.data['last_name'][0],
u'Ensure this field has no more than 30 characters.')
self.assertEqual(response.status_code, 400)

@all_requests
def grant_perms_form_builder(self, url, request):

assert 'Authorization' in request.headers
assert request.headers.get('Authorization').startswith('Token')

response = requests.Response()
response.status_code = 201
response._content = \
{
"detail": "Successfully granted default model level perms to"
" user."
}
return response

def test_create_user_with_given_name(self):
with HTTMock(self.grant_perms_form_builder):
with self.settings(KPI_FORMBUILDER_URL='http://test_formbuilder$'):
extra_data = {"username": "rust"}
self._login_user_and_profile(extra_post_data=extra_data)

0 comments on commit fbdc902

Please sign in to comment.