def test_valid(self): email = "*****@*****.**" form = EmailUserCreationForm( {'email': email, 'password1': 'password', 'password2': 'password'}) self.assertTrue(form.is_valid())
def test_valid(self): email = "*****@*****.**" form = EmailUserCreationForm({ 'email': email, 'password1': 'password', 'password2': 'password' }) self.assertTrue(form.is_valid())
def test_email_not_valid(self): email = "user.example.com" form = EmailUserCreationForm( {'email': email, 'password1': 'password', 'password2': 'password'}) self.assertFalse(form.is_valid()) self.assertIn('email', form.errors)
def test_email_not_valid(self): email = "user.example.com" form = EmailUserCreationForm({ 'email': email, 'password1': 'password', 'password2': 'password' }) self.assertFalse(form.is_valid()) self.assertIn('email', form.errors)
def test_user_exists(self): email = "*****@*****.**" EmailUserFactory(email=email) form = EmailUserCreationForm( {'email': email, 'password1': 'password', 'password2': 'password'}) self.assertFalse(form.is_valid()) self.assertIn('email', form.errors)
def test_password_too_short(self): email = "*****@*****.**" form = EmailUserCreationForm( {'email': email, 'password1': 'passw', 'password2': 'passw'}) self.assertFalse(form.is_valid()) self.assertIn('password1', form.errors) self.assertIn('password2', form.errors)
def test_user_exists(self): email = "*****@*****.**" EmailUserFactory(email=email) form = EmailUserCreationForm({ 'email': email, 'password1': 'password', 'password2': 'password' }) self.assertFalse(form.is_valid()) self.assertIn('email', form.errors)
def test_password_too_short(self): email = "*****@*****.**" form = EmailUserCreationForm({ 'email': email, 'password1': 'passw', 'password2': 'passw' }) self.assertFalse(form.is_valid()) self.assertIn('password1', form.errors) self.assertIn('password2', form.errors)
def validate(self, attrs): attrs = super().validate(attrs) email = attrs.get('email') password = attrs.get('password') form = EmailUserCreationForm(data={ 'email': email, 'password1': password, 'password2': password, }) if not form.is_valid(): raise exceptions.ValidationError(form.errors) return attrs