Created
November 20, 2018 12:55
-
-
Save sekayasin/83e8945e689d57a32a0ed68dccdc4474 to your computer and use it in GitHub Desktop.
Testing User creation for Author's Heaven
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, Client | |
from django.urls import reverse | |
from rest_framework import status | |
from .models import User | |
from .views import RegistrationAPIView | |
class RegistrationAPIViewTest(TestCase): | |
def setUp(self): | |
self.testClient = Client() | |
self.user_info = { | |
'username': 'sekayasin', | |
'email': 'yasin.sekabira@andela.com', | |
'password': 'p@55w0rd' | |
} | |
User.objects.create_user(**self.user_info) | |
def test_register_a_user(self): | |
# Register a new user | |
response = self.testClient.post('/api/users', **self.user_info) | |
self.assertEquals(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