forked from mirrors/bookwyrm
Fixes tests
This commit is contained in:
parent
4575fe24c7
commit
33b5639af0
3 changed files with 17 additions and 12 deletions
|
@ -29,15 +29,19 @@ def password_reset_email(reset_code):
|
|||
@app.task
|
||||
def send_email(recipient, message_name, data):
|
||||
""" use a task to send the email """
|
||||
subject = get_template(
|
||||
"email/{}/subject.html".format(message_name)
|
||||
).render(data).strip()
|
||||
html_content = get_template(
|
||||
"email/{}/html_content.html".format(message_name)
|
||||
).render(data).strip()
|
||||
text_content = get_template(
|
||||
"email/{}/text_content.html".format(message_name)
|
||||
).render(data).strip()
|
||||
subject = (
|
||||
get_template("email/{}/subject.html".format(message_name)).render(data).strip()
|
||||
)
|
||||
html_content = (
|
||||
get_template("email/{}/html_content.html".format(message_name))
|
||||
.render(data)
|
||||
.strip()
|
||||
)
|
||||
text_content = (
|
||||
get_template("email/{}/text_content.html".format(message_name))
|
||||
.render(data)
|
||||
.strip()
|
||||
)
|
||||
|
||||
email = EmailMultiAlternatives(subject, text_content, None, [recipient])
|
||||
email.attach_alternative(html_content, "text/html")
|
||||
|
|
|
@ -101,14 +101,15 @@ class InviteViews(TestCase):
|
|||
""" send an invite """
|
||||
req = models.InviteRequest.objects.create(email="fish@example.com")
|
||||
|
||||
view = views.InviteRequest.as_view()
|
||||
request = self.factory.post("", {"id": req.id})
|
||||
view = views.ManageInviteRequests.as_view()
|
||||
request = self.factory.post("", {"invite-request": req.id})
|
||||
request.user = self.local_user
|
||||
request.user.is_superuser = True
|
||||
|
||||
with patch("bookwyrm.emailing.send_email.delay") as mock:
|
||||
view(request)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
req.refresh_from_db()
|
||||
self.assertIsNotNone(req.invite)
|
||||
|
||||
def test_ignore_invite_request(self):
|
||||
|
|
|
@ -118,7 +118,7 @@ class ManageInviteRequests(View):
|
|||
|
||||
invite_request.save()
|
||||
emailing.invite_email(invite_request)
|
||||
return redirect('settings-invite-requests')
|
||||
return redirect("settings-invite-requests")
|
||||
|
||||
|
||||
class InviteRequest(View):
|
||||
|
|
Loading…
Reference in a new issue