コード例 #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'))
コード例 #2
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'))
コード例 #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'))
コード例 #5
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)
コード例 #6
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'))
コード例 #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())