-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! ✨(emails) use mjml to generate html and text emails
- Loading branch information
Showing
6 changed files
with
49 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,20 @@ MORK_CELERY_RESULT_BACKEND=redis://redis:6379/0 | |
MORK_CELERY_BROKER_TRANSPORT_OPTIONS={} | ||
MORK_CELERY_TASK_DEFAULT_QUEUE=celery | ||
|
||
# Emails | ||
MORK_EMAIL_HOST=mailcatcher | ||
MORK_EMAIL_HOST_USER= | ||
MORK_EMAIL_HOST_PASSWORD= | ||
MORK_EMAIL_PORT=1025 | ||
MORK_EMAIL_USE_TLS=False | ||
[email protected] | ||
MORK_EMAIL_RATE_LIMIT=100/m | ||
MORK_EMAIL_MAX_RETRIES=3 | ||
MORK_EMAIL_SITE_NAME="France Université Numérique" | ||
MORK_EMAIL_SITE_BASE_URL=https://fun-mooc.fr | ||
MORK_EMAIL_SITE_LOGIN_URL=https://lms.fun-mooc.fr/login | ||
|
||
|
||
# Python | ||
PYTHONPATH=/app | ||
|
||
|
@@ -48,16 +62,3 @@ MYSQL_PASSWORD=password | |
POSTGRES_DB=mork-db | ||
POSTGRES_USER=fun | ||
POSTGRES_PASSWORD=pass | ||
|
||
# Emails | ||
EMAIL_HOST=mailcatcher | ||
EMAIL_HOST_USER= | ||
EMAIL_HOST_PASSWORD= | ||
EMAIL_PORT=1025 | ||
EMAIL_USE_TLS=False | ||
[email protected] | ||
EMAIL_RATE_LIMIT=100/m | ||
EMAIL_MAX_RETRIES=3 | ||
EMAIL_SITE_NAME="France Université Numérique" | ||
EMAIL_SITE_BASE_URL=https://fun-mooc.fr | ||
EMAIL_SITE_LOGIN_URL=https://lms.fun-mooc.fr/login |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
import pytest | ||
|
||
from mork.exceptions import EmailSendError | ||
from mork.exceptions import EmailSendError, EmailTemplateError | ||
from mork.mail import render_template, send_email | ||
|
||
|
||
|
@@ -28,6 +28,8 @@ def test_render_template(): | |
assert template_vars["site"]["name"] in render_html | ||
assert template_vars["site"]["url"] in render_html | ||
assert template_vars["site"]["login_url"] in render_html | ||
with open("test.html", "w") as f: | ||
f.write(render_html) | ||
assert 'src="data:' in render_html | ||
|
||
render_text = render_template("warning_email.txt", template_vars) | ||
|
@@ -68,3 +70,18 @@ def test_send_email_with_smtp_exception(monkeypatch): | |
|
||
with pytest.raises(EmailSendError, match="Failed sending an email"): | ||
send_email(email_address=test_address, username=test_username) | ||
|
||
|
||
def test_send_email_with_template_misconfiguration(monkeypatch): | ||
"""Test the `send_email` function with an SMTP exception.""" | ||
|
||
mock_SMTP = MagicMock() | ||
monkeypatch.setattr("mork.mail.smtplib.SMTP", mock_SMTP) | ||
|
||
monkeypatch.setattr("mork.mail.settings.EMAIL_SITE_LOGIN_URL", "") | ||
|
||
test_address = "[email protected]" | ||
test_username = "JohnDoe" | ||
|
||
with pytest.raises(EmailTemplateError, match="Email template misconfigured."): | ||
send_email(email_address=test_address, username=test_username) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters