Skip to content

Instantly share code, notes, and snippets.

@waracci
Last active December 19, 2018 11:19
Show Gist options
  • Save waracci/93d2a3cecf6aa8dc4061a854538c1413 to your computer and use it in GitHub Desktop.
Save waracci/93d2a3cecf6aa8dc4061a854538c1413 to your computer and use it in GitHub Desktop.
Test that a user registers with correct details (Email and password)
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)
@waracci
Copy link
Author

waracci commented Dec 19, 2018

Good work. However, the blank spaces within the methods should be removed as I think they do not conform to PEP 8 standards

Thanks let me review accordingly!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment