Пример #1
0
 def test_clean_password2_valid(self):
     self.assertTrue(self.user.check_password('test1234'))
     form = SettingsForm(data={
         'password1': 'test2345',
         'password2': 'test2345'
     }, instance=self.user)
     self.assertTrue(form.is_valid())
     self.assertTrue(self.user.check_password('test2345'))
 def test_clean_password2_valid(self):
     self.assertTrue(self.user.check_password('test1234'))
     form = SettingsForm(data={
         'password1': 'test2345',
         'password2': 'test2345'
     },
                         instance=self.user)
     self.assertTrue(form.is_valid())
     self.assertTrue(self.user.check_password('test2345'))
Пример #3
0
 def test_clean_email_change_user(self):
     form = SettingsForm(data={
         'email': '*****@*****.**'}, instance=self.user)
     self.assertTrue(form.is_valid())
     self.assertEqual(len(Action.objects.all()), 1)
     self.assertEqual(Action.objects.all()[0].data, '*****@*****.**')
     self.assertEqual(Action.objects.all()[0].user, self.user)
     self.assertEqual(Action.objects.all()[0].atype,
                      ACTION_TYPES.change_email)
Пример #4
0
 def test_clean_password2_one_empty(self):
     form = SettingsForm(data={
         'password1': 'test2345',
         'password2': ''
     }, instance=self.user)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['password2'],
                      [PASSWORD_MISMATCH_ERROR])
     self.assertTrue(self.user.check_password('test1234'))
 def test_clean_email_change_user(self):
     form = SettingsForm(data={'email': '*****@*****.**'},
                         instance=self.user)
     self.assertTrue(form.is_valid())
     self.assertEqual(len(Action.objects.all()), 1)
     self.assertEqual(Action.objects.all()[0].data, '*****@*****.**')
     self.assertEqual(Action.objects.all()[0].user, self.user)
     self.assertEqual(Action.objects.all()[0].atype,
                      ACTION_TYPES.change_email)
 def test_clean_password2_one_empty(self):
     form = SettingsForm(data={
         'password1': 'test2345',
         'password2': ''
     },
                         instance=self.user)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['password2'], [PASSWORD_MISMATCH_ERROR])
     self.assertTrue(self.user.check_password('test1234'))
Пример #7
0
 def test_clean_password2_empty(self):
     form = SettingsForm(data={}, instance=self.user)
     self.assertTrue(form.is_valid())
     self.assertTrue(self.user.check_password('test1234'))
Пример #8
0
 def test_clean_email_duplicate_address(self):
     User.objects.create_user(username='******', email='*****@*****.**')
     form = SettingsForm(data={
         'email': '*****@*****.**'}, instance=self.user)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['email'], [DUPLICATE_EMAIL_ERROR])
Пример #9
0
 def test_clean_email_no_change(self):
     form = SettingsForm(data={
         'email': '*****@*****.**'}, instance=self.user)
     self.assertTrue(form.is_valid())
Пример #10
0
 def test_clean_password2_empty(self):
     form = SettingsForm(data={}, instance=self.user)
     self.assertTrue(form.is_valid())
     self.assertTrue(self.user.check_password('test1234'))
Пример #11
0
 def test_clean_email_duplicate_address(self):
     User.objects.create_user(username='******', email='*****@*****.**')
     form = SettingsForm(data={'email': '*****@*****.**'},
                         instance=self.user)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['email'], [DUPLICATE_EMAIL_ERROR])
Пример #12
0
 def test_clean_email_no_change(self):
     form = SettingsForm(data={'email': '*****@*****.**'}, instance=self.user)
     self.assertTrue(form.is_valid())