Merge pull request #2426 from bookwyrm-social/password-reset-email

Don't use task for password reset emails
This commit is contained in:
Mouse Reeve 2022-11-23 22:10:47 -08:00 committed by GitHub
commit 9dd0e22a47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -38,7 +38,7 @@ def password_reset_email(reset_code):
data = email_data()
data["reset_link"] = reset_code.link
data["user"] = reset_code.user.display_name
send_email.delay(reset_code.user.email, *format_email("password_reset", data))
send_email(reset_code.user.email, *format_email("password_reset", data))
def moderation_report_email(report):

View file

@ -11,6 +11,7 @@ from bookwyrm import emailing, models
class Emailing(TestCase):
"""every response to a get request, html or json"""
# pylint: disable=invalid-name
def setUp(self):
"""we need basic test data and mocks"""
self.factory = RequestFactory()
@ -41,10 +42,12 @@ class Emailing(TestCase):
self.assertEqual(args[1], "You're invited to join BookWyrm!")
self.assertEqual(len(args), 4)
def test_password_reset_email(self, email_mock):
def test_password_reset_email(self, _):
"""load the password reset email"""
reset = models.PasswordReset.objects.create(user=self.local_user)
emailing.password_reset_email(reset)
with patch("bookwyrm.emailing.send_email") as email_mock:
emailing.password_reset_email(reset)
self.assertEqual(email_mock.call_count, 1)
args = email_mock.call_args[0]