Last active
December 19, 2018 11:19
-
-
Save waracci/93d2a3cecf6aa8dc4061a854538c1413 to your computer and use it in GitHub Desktop.
Test that a user registers with correct details (Email and password)
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
from django.test import TestCase | |
from rest_framework.test import APIClient | |
from rest_framework import status | |
class UserRegistrationTestCase(TestCase): | |
"""This class defines the test suite for the User authentication model.""" | |
def setUp(self): | |
"""Test setup for running tests.""" | |
self.registration_endpoint = "api/auth/v1/register" | |
self.client = APIClient() | |
self.user_data = { | |
"email": "[email protected]", | |
"password": "TestPassword1234", | |
"confirm_password": "TestPassword1234", | |
"username": "tested_user", | |
"bio": """I am passionate about tech, | |
collaborative initiatives and | |
building solutions that add value to society.""" | |
} | |
def test_user_can_register_successfully(self): | |
"""Test that the user can register successfully.""" | |
response = self.client.post( | |
self.registration_endpoint, | |
self.user_data, | |
format="json") | |
self.assertEqual(response.status_code, status.HTTP_201_CREATED) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks let me review accordingly!!!