mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-28 20:41:46 +00:00
Merge pull request #2426 from bookwyrm-social/password-reset-email
Don't use task for password reset emails
This commit is contained in:
commit
9dd0e22a47
2 changed files with 6 additions and 3 deletions
|
@ -38,7 +38,7 @@ def password_reset_email(reset_code):
|
||||||
data = email_data()
|
data = email_data()
|
||||||
data["reset_link"] = reset_code.link
|
data["reset_link"] = reset_code.link
|
||||||
data["user"] = reset_code.user.display_name
|
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):
|
def moderation_report_email(report):
|
||||||
|
|
|
@ -11,6 +11,7 @@ from bookwyrm import emailing, models
|
||||||
class Emailing(TestCase):
|
class Emailing(TestCase):
|
||||||
"""every response to a get request, html or json"""
|
"""every response to a get request, html or json"""
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""we need basic test data and mocks"""
|
"""we need basic test data and mocks"""
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
|
@ -41,9 +42,11 @@ class Emailing(TestCase):
|
||||||
self.assertEqual(args[1], "You're invited to join BookWyrm!")
|
self.assertEqual(args[1], "You're invited to join BookWyrm!")
|
||||||
self.assertEqual(len(args), 4)
|
self.assertEqual(len(args), 4)
|
||||||
|
|
||||||
def test_password_reset_email(self, email_mock):
|
def test_password_reset_email(self, _):
|
||||||
"""load the password reset email"""
|
"""load the password reset email"""
|
||||||
reset = models.PasswordReset.objects.create(user=self.local_user)
|
reset = models.PasswordReset.objects.create(user=self.local_user)
|
||||||
|
|
||||||
|
with patch("bookwyrm.emailing.send_email") as email_mock:
|
||||||
emailing.password_reset_email(reset)
|
emailing.password_reset_email(reset)
|
||||||
|
|
||||||
self.assertEqual(email_mock.call_count, 1)
|
self.assertEqual(email_mock.call_count, 1)
|
||||||
|
|
Loading…
Reference in a new issue