Beispiel #1
0
 def test_inactive_user(self):
     """
     Test that inactive user cannot receive password reset email.
     """
     self.user.is_active = False
     self.user.save()
     form = CustomPasswordResetForm({'email': self.user.email})
     self.assertTrue(form.is_valid())
     form.save()
     self.assertEqual(len(mail.outbox), 0)
Beispiel #2
0
 def test_inactive_user(self):
     """
     Test that inactive user cannot receive password reset email.
     """
     self.user.is_active = False
     self.user.save()
     form = CustomPasswordResetForm({'email': self.user.email})
     self.assertTrue(form.is_valid())
     form.save()
     self.assertEqual(len(mail.outbox), 0)
Beispiel #3
0
 def test_unusable_password(self):
     data = {"email": "*****@*****.**"}
     form = CustomPasswordResetForm(data)
     self.assertTrue(form.is_valid())
     self.user.set_unusable_password()
     self.user.save()
     form = CustomPasswordResetForm(data)
     # The form itself is valid, but no email is sent
     self.assertTrue(form.is_valid())
     form.save()
     self.assertEqual(len(mail.outbox), 0)
Beispiel #4
0
 def test_custom_email_subject(self):
     data = {'email': '*****@*****.**'}
     form = CustomPasswordResetForm(data)
     self.assertTrue(form.is_valid())
     # Since we're not providing a request object, we must provide a
     # domain_override to prevent the save operation from failing in the
     # potential case where contrib.sites is not installed. Refs #16412.
     form.save(domain_override='example.com')
     self.assertEqual(len(mail.outbox), 1)
     self.assertEqual(mail.outbox[0].subject,
                      'Reset your example.com password')
Beispiel #5
0
 def test_unusable_password(self):
     data = {"email": "*****@*****.**"}
     form = CustomPasswordResetForm(data)
     self.assertTrue(form.is_valid())
     self.user.set_unusable_password()
     self.user.save()
     form = CustomPasswordResetForm(data)
     # The form itself is valid, but no email is sent
     self.assertTrue(form.is_valid())
     form.save()
     self.assertEqual(len(mail.outbox), 0)
Beispiel #6
0
 def test_custom_email_subject(self):
     data = {'email': '*****@*****.**'}
     form = CustomPasswordResetForm(data)
     self.assertTrue(form.is_valid())
     # Since we're not providing a request object, we must provide a
     # domain_override to prevent the save operation from failing in the
     # potential case where contrib.sites is not installed. Refs #16412.
     form.save(domain_override='example.com')
     self.assertEqual(len(mail.outbox), 1)
     self.assertEqual(mail.outbox[0].subject,
                      'Reset your example.com password')
Beispiel #7
0
 def test_cleaned_data(self):
     form = CustomPasswordResetForm({'email': self.user.email})
     self.assertTrue(form.is_valid())
     form.save(domain_override='example.com')
     self.assertEqual(form.cleaned_data['email'], self.user.email)
     self.assertEqual(len(mail.outbox), 1)
Beispiel #8
0
 def test_cleaned_data(self):
     form = CustomPasswordResetForm({'email': self.user.email})
     self.assertTrue(form.is_valid())
     form.save(domain_override='example.com')
     self.assertEqual(form.cleaned_data['email'], self.user.email)
     self.assertEqual(len(mail.outbox), 1)