Skip to content

Commit

Permalink
#43 Assert test db integrityError
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorcx committed Oct 2, 2019
1 parent 4e1b450 commit 6528028
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from rest_framework.test import APITestCase
from django.urls import reverse
from django.db import IntegrityError


class UserRegistrationAPIViewTestCase(APITestCase):
Expand Down Expand Up @@ -44,25 +45,23 @@ def test_unique_email_validation(self):
Test to try to create a user with a registered email
"""

user_data = {
user1_data = {
"username": "vitas",
"email": "[email protected]",
"password": "VitasIsAwesome",
"confirm_password": "VitasIsAwesome"
}

response = self.client.post(self.url, user_data)
self.assertEqual(201, response.status_code)

user_data = {
user2_data = {
"username": "Reanu_Reves",
"email": "[email protected]",
"password": "cyberpunk2077",
"confirm_password": "cyberpunk2077"
}

response = self.client.post(self.url, user_data)
self.assertEqual(400, response.status_code)
response = self.client.post(self.url, user1_data)
self.assertEqual(201, response.status_code)
with self.assertRaises(IntegrityError):
response = self.client.post(self.url, user2_data)


def test_unique_username_validation(self):
"""
Expand Down

0 comments on commit 6528028

Please sign in to comment.