Skip to content

Instantly share code, notes, and snippets.

@sekayasin
Created November 20, 2018 12:55
Show Gist options
  • Save sekayasin/83e8945e689d57a32a0ed68dccdc4474 to your computer and use it in GitHub Desktop.
Save sekayasin/83e8945e689d57a32a0ed68dccdc4474 to your computer and use it in GitHub Desktop.
Testing User creation for Author's Heaven
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