-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
76 additions
and
21 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
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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import pytest | ||
|
||
from h.emails.flag_notification import generate | ||
from h.services.email import EmailTag | ||
|
||
|
||
class TestGenerate: | ||
|
@@ -23,7 +24,7 @@ def test_appropriate_return_values( | |
html_renderer.string_response = "HTML output" | ||
text_renderer.string_response = "Text output" | ||
|
||
recipients, subject, text, html = generate( | ||
recipients, subject, text, tag, html = generate( | ||
pyramid_request, | ||
email="[email protected]", | ||
incontext_link="http://hyp.is/a/ann1", | ||
|
@@ -32,6 +33,7 @@ def test_appropriate_return_values( | |
assert recipients == ["[email protected]"] | ||
assert subject == "An annotation has been flagged" | ||
assert html == "HTML output" | ||
assert tag == EmailTag.FLAG_NOTIFICATION | ||
assert text == "Text output" | ||
|
||
@pytest.fixture | ||
|
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 |
---|---|---|
|
@@ -99,7 +99,7 @@ def test_supports_non_ascii_display_names( | |
parent_user.display_name = "Parent 👩" | ||
reply_user.display_name = "Child 👧" | ||
|
||
(_, subject, _, _) = generate(pyramid_request, notification) | ||
(_, subject, _, _, _) = generate(pyramid_request, notification) | ||
|
||
assert subject == "Child 👧 has replied to your annotation" | ||
|
||
|
@@ -130,28 +130,28 @@ def test_returns_text_and_body_results_from_renderers( | |
html_renderer.string_response = "HTML output" | ||
text_renderer.string_response = "Text output" | ||
|
||
_, _, text, html = generate(pyramid_request, notification) | ||
_, _, text, _, html = generate(pyramid_request, notification) | ||
|
||
assert html == "HTML output" | ||
assert text == "Text output" | ||
|
||
def test_returns_subject_with_reply_display_name( | ||
self, notification, pyramid_request | ||
): | ||
_, subject, _, _ = generate(pyramid_request, notification) | ||
_, subject, _, _, _ = generate(pyramid_request, notification) | ||
|
||
assert subject == "Ron Burgundy has replied to your annotation" | ||
|
||
def test_returns_subject_with_reply_username( | ||
self, notification, pyramid_request, reply_user | ||
): | ||
reply_user.display_name = None | ||
_, subject, _, _ = generate(pyramid_request, notification) | ||
_, subject, _, _, _ = generate(pyramid_request, notification) | ||
|
||
assert subject == "ron has replied to your annotation" | ||
|
||
def test_returns_parent_email_as_recipients(self, notification, pyramid_request): | ||
recipients, _, _, _ = generate(pyramid_request, notification) | ||
recipients, _, _, _, _ = generate(pyramid_request, notification) | ||
|
||
assert recipients == ["[email protected]"] | ||
|
||
|
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import pytest | ||
|
||
from h.emails.signup import generate | ||
from h.services.email import EmailTag | ||
|
||
|
||
@pytest.mark.usefixtures("routes") | ||
|
@@ -27,7 +28,7 @@ def test_appropriate_return_values( | |
html_renderer.string_response = "HTML output" | ||
text_renderer.string_response = "Text output" | ||
|
||
recipients, subject, text, html = generate( | ||
recipients, subject, text, tag, html = generate( | ||
pyramid_request, | ||
user_id=1234, | ||
email="[email protected]", | ||
|
@@ -37,6 +38,7 @@ def test_appropriate_return_values( | |
assert recipients == ["[email protected]"] | ||
assert subject == "Please activate your account" | ||
assert html == "HTML output" | ||
assert tag == EmailTag.ACTIVATION | ||
assert text == "Text output" | ||
|
||
def test_jinja_templates_render(self, pyramid_config, pyramid_request): | ||
|
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
from h import __version__ | ||
from h.emails.test import generate | ||
from h.services.email import EmailTag | ||
|
||
|
||
class TestGenerate: | ||
|
@@ -26,13 +27,14 @@ def test_appropriate_return_values( | |
html_renderer.string_response = "HTML output" | ||
text_renderer.string_response = "Text output" | ||
|
||
recipients, subject, text, html = generate( | ||
recipients, subject, text, tag, html = generate( | ||
pyramid_request, "[email protected]" | ||
) | ||
|
||
assert recipients == ["[email protected]"] | ||
assert subject == "Test mail" | ||
assert html == "HTML output" | ||
assert tag == EmailTag.TEST | ||
assert text == "Text output" | ||
|
||
def test_jinja_templates_render(self, pyramid_config, pyramid_request): | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
import pytest | ||
|
||
from h.services.email import EmailService, factory | ||
from h.services.email import EmailService, EmailTag, factory | ||
|
||
|
||
class TestEmailService: | ||
|
@@ -12,13 +12,15 @@ def test_send_creates_email_message(self, email_service, pyramid_mailer): | |
recipients=["[email protected]"], | ||
subject="My email subject", | ||
body="Some text body", | ||
tag=EmailTag.TEST, | ||
) | ||
|
||
pyramid_mailer.message.Message.assert_called_once_with( | ||
recipients=["[email protected]"], | ||
subject="My email subject", | ||
body="Some text body", | ||
html=None, | ||
extra_headers={"X-MC-Tags": EmailTag.TEST}, | ||
) | ||
|
||
def test_send_creates_email_message_with_html_body( | ||
|
@@ -28,6 +30,7 @@ def test_send_creates_email_message_with_html_body( | |
recipients=["[email protected]"], | ||
subject="My email subject", | ||
body="Some text body", | ||
tag=EmailTag.TEST, | ||
html="<p>An HTML body</p>", | ||
) | ||
|
||
|
@@ -36,6 +39,7 @@ def test_send_creates_email_message_with_html_body( | |
subject="My email subject", | ||
body="Some text body", | ||
html="<p>An HTML body</p>", | ||
extra_headers={"X-MC-Tags": EmailTag.TEST}, | ||
) | ||
|
||
def test_send_dispatches_email_using_request_mailer( | ||
|
@@ -48,6 +52,7 @@ def test_send_dispatches_email_using_request_mailer( | |
recipients=["[email protected]"], | ||
subject="My email subject", | ||
body="Some text body", | ||
tag=EmailTag.TEST, | ||
) | ||
|
||
request_mailer.send_immediately.assert_called_once_with(message) | ||
|
@@ -61,6 +66,7 @@ def test_raises_smtplib_exception(self, email_service, pyramid_mailer): | |
recipients=["[email protected]"], | ||
subject="My email subject", | ||
body="Some text body", | ||
tag=EmailTag.TEST, | ||
) | ||
|
||
@pytest.fixture | ||
|
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
import pytest | ||
|
||
from h.services.email import EmailTag | ||
from h.tasks import mailer | ||
|
||
|
||
|
@@ -14,6 +15,7 @@ def test_send_retries_if_mailing_fails(email_service): | |
recipients=["[email protected]"], | ||
subject="My email subject", | ||
body="Some text body", | ||
tag=EmailTag.TEST, | ||
) | ||
|
||
assert mailer.send.retry.called | ||
|