Verified Commit 5812cf68 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Add tests for two registrations with same email

parent c77b1407
......@@ -97,8 +97,21 @@ class RegistrationTest(TestCase):
self.registration.clean()
def test_unique_email_user(self):
get_user_model().objects.create_user('johnnydoe',
'johndoe@example.com')
self.registration.clean()
user = get_user_model().objects.create_user('johnnydoe',
'johndoe@example.com')
with self.assertRaises(ValidationError):
self.registration.clean()
user.delete()
self.registration.clean()
Registration.objects.create(
first_name='John',
last_name='Doe',
birthday=timezone.now().replace(year=1990),
email='johndoe@example.com',
)
with self.assertRaises(ValidationError):
self.registration.clean()
......@@ -117,6 +130,18 @@ class RegistrationTest(TestCase):
with self.assertRaises(ValidationError):
self.registration.clean()
user.delete()
self.registration.clean()
Registration.objects.create(
first_name='John',
last_name='Doe',
birthday=timezone.now().replace(year=1990),
student_number='s1234567'
)
with self.assertRaises(ValidationError):
self.registration.clean()
def test_unique_username_user(self):
self.registration.username = 'johndoe'
self.registration.clean()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment