Last active
October 18, 2018 18:05
-
-
Save maxwellgithinji/41b5a197eec6eb35f750ae69be16bbd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
User authentication test cases | |
""" | |
from rest_framework.test import APIClient | |
from rest_framework import status | |
from django.core.urlresolvers import reverse | |
class UserAuth(TestCase): | |
""" | |
Test user Authentication endpoints | |
:param: TestCase: Testing class initializer | |
""" | |
def setUp(self): | |
"""Define the test client and other test variables.""" | |
self.client = APIClient() | |
self.user_data = { | |
'username': 'maxgit', | |
'email': 'max@git.com', | |
'password': '@amg1t$$' | |
} | |
self.response = self.client.post( | |
reverse('register'), | |
self.user_data, | |
format="json" | |
) | |
def test_api_register_user(self): | |
"""Test the api can register a new user""" | |
self.assertEqual(self.response.status_code, status.HTTP_201_CREATED) | |
self.assertJSONEqual( | |
str(response.content, encoding='utf8'), | |
{'Message': 'Registration Succesful'} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment