Beispiel #1
0
 def test_013_NewUserNoEmail(self):
     """Test error generated when email address is not provided"""
     f = forms.NewUserForm(
         data={
             'first_name': 'Chester',
             'last_name': 'Tester',
             'username': '******',
             'password': '******',
             'confirm_password': '******'
         })
     self.assertFalse(f.is_valid())
     self.assertEqual(f.errors,
                      {'email': [u'You must provide an email address']})
Beispiel #2
0
 def test_020_NewUserOK(self):
     """Test that a valid user entry validates correctly"""
     f = forms.NewUserForm(
         data={
             'first_name': 'Chester',
             'last_name': 'Tester',
             'email': '*****@*****.**',
             'username': '******',
             'password': '******',
             'confirm_password': '******'
         })
     self.assertTrue(f.is_valid())
     self.assertEqual(f.errors, {})
Beispiel #3
0
 def test_010_NewUserNoName(self):
     """Test error generated when neither first or last name is provided"""
     f = forms.NewUserForm(
         data={
             'email': '*****@*****.**',
             'username': '******',
             'password': '******',
             'confirm_password': '******'
         })
     self.assertFalse(f.is_valid())
     self.assertEqual(f.errors, {
         'first_name': [u'You must provide both your first and last name']
     })
Beispiel #4
0
 def test_014_NewUserNoUserName(self):
     """Test error generated when username is not provided"""
     f = forms.NewUserForm(
         data={
             'first_name': 'Chester',
             'last_name': 'Tester',
             'email': '*****@*****.**',
             'password': '******',
             'confirm_password': '******'
         })
     self.assertFalse(f.is_valid())
     self.assertEqual(f.errors,
                      {'username': [u'You must provide a username']})
Beispiel #5
0
 def test_032_NewUserNoDuplicateUsername(self):
     """Test that a duplicate usernames are trapped and the 2nd user cannot be created"""
     f = forms.NewUserForm(
         data={
             'first_name': 'Chester',
             'last_name': 'Tester',
             'email': '*****@*****.**',
             'username': '******',
             'password': '******',
             'confirm_password': '******'
         })
     self.assertTrue(f.is_valid())
     f.save()
     f1 = forms.NewUserForm(
         data={
             'first_name': 'Chester',
             'last_name': 'Tester',
             'email': '*****@*****.**',
             'username': '******',
             'password': '******',
             'confirm_password': '******'
         })
     self.assertFalse(f1.is_valid())
Beispiel #6
0
 def test_017_NewUserPasswordNotConfirmed(self):
     """Test error generated when password and confirmation password are different"""
     f = forms.NewUserForm(
         data={
             'first_name': 'chester',
             'last_name': 'tester',
             'email': '*****@*****.**',
             'username': '******',
             'password': '******',
             'confirm_password': '******'
         })
     self.assertFalse(f.is_valid())
     self.assertEqual(f.errors,
                      {'confirm_password': [u'Passwords do not match']})
Beispiel #7
0
 def test_016_NewUserNoConfirmationPassword(self):
     """Test error generated when confirmation password is not provided"""
     f = forms.NewUserForm(
         data={
             'first_name': 'Chester',
             'last_name': 'Tester',
             'email': '*****@*****.**',
             'username': '******',
             'password': '******'
         })
     self.assertFalse(f.is_valid())
     self.assertEqual(
         f.errors,
         {'confirm_password': [u'You must re-enter the password']})
Beispiel #8
0
 def test_021_NewUserSave(self):
     """Test that a valid user entry is saved correctly"""
     f = forms.NewUserForm(
         data={
             'first_name': 'Chester',
             'last_name': 'Tester',
             'email': '*****@*****.**',
             'username': '******',
             'password': '******',
             'confirm_password': '******'
         })
     self.assertTrue(f.is_valid())
     self.assertEqual(f.errors, {})
     f.save()
     u = models.User.objects.all()
     self.assertEqual(len(u), 1)
     self.assertEqual(u[0].first_name, "Chester")
     self.assertEqual(u[0].last_name, "Tester")