def test_user_create(self): data = { 'email': '*****@*****.**', 'password1': 'password', 'password2': 'password', } form = CtsUserCreationForm(data=data) self.assertTrue(form.is_valid()) user = form.save() self.assertEqual(user.email, data['email'])
def test_duplicate_email(self): data = { 'email': '*****@*****.**', 'password1': 'password', 'password2': 'password', } initial = {'is_active': True, 'name': '', 'email': ''} CtsUserFactory(email=data['email']) form = CtsUserCreationForm(initial=initial, data=data) self.assertFalse(form.is_valid()) self.assertIn('email', form.errors)