def send_password_reset_email(self, request, queryset): for user in queryset: send_password_reset_email(user.email, request=request) self.message_user( request, '{} password reset email(s) sent'.format(queryset.count()) )
def send_password_reset_email(self, request, queryset): for user in queryset: send_password_reset_email(user.email, request=request) self.message_user( request, '{} password reset email(s) sent'.format(queryset.count()) )
def test_send_password_reset_email(self): send_password_reset_email(self.email, request=self.request) self.assertEqual(len(mail.outbox), 1) message = mail.outbox[0] self.assertEqual(message.to, [self.email]) self.assertEqual(message.from_email, 'webmaster@localhost') self.assertEqual(message.subject, 'Password reset') self.assertIn( 'http://{SERVER_NAME}:{SERVER_PORT}'.format(**self.request.META), message.message().as_string())
def test_send_password_reset_email(self): send_password_reset_email(self.email, request=self.request) self.assertEqual(len(mail.outbox), 1) message = mail.outbox[0] self.assertEqual(message.to, [self.email]) self.assertEqual(message.from_email, 'webmaster@localhost') self.assertEqual(message.subject, 'Password reset') self.assertIn( 'http://{SERVER_NAME}:{SERVER_PORT}'.format(**self.request.META), message.message().as_string() )
def test_send_with_no_request(self): with patch('v1.email.create_request_for_email') as p: send_password_reset_email(self.email) p.assert_called_once_with()
def test_send_with_no_request(self): with patch('v1.email.create_request_for_email') as p: send_password_reset_email(self.email) p.assert_called_once_with()