def test_invalid_email(self): # Test that form is invalid with incorrect email. data = self.get_test_userdata() data['email'] = 'john#example.com' form = RegistrationForm(data) self.assertFalse(form.is_valid()) self.assertEqual(form['email'].errors, [u'Enter a valid e-mail address.'])
def test_invalid_password(self): # Test that form is invalid if password is too short. data = self.get_test_userdata() data['password'] = '******' form = RegistrationForm(data) self.assertFalse(form.is_valid()) self.assertEqual(form['password'].errors, [u'Ensure this value has at least 5 characters (it has 3).'])
def test_success(self): # Test that form is valid with correct data. data = self.get_test_userdata() form = RegistrationForm(data) self.assertTrue(form.is_valid())