-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for echo-to-stdout and update README.
- Loading branch information
Showing
4 changed files
with
47 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
from unittest.mock import MagicMock | ||
|
||
from django.core.mail import EmailMessage | ||
from django.test import override_settings | ||
from django.test.testcases import SimpleTestCase | ||
|
||
from sendgrid_backend.mail import SendgridBackend | ||
|
||
|
||
class TestEchoToOutput(SimpleTestCase): | ||
def test_echo(self): | ||
settings = { | ||
"DEBUG": True, | ||
"SENDGRID_API_KEY": os.environ.get("SENDGRID_API_KEY", ""), | ||
"EMAIL_BACKEND": "sendgrid_backend.SendgridBackend", | ||
"SENDGRID_ECHO_TO_STDOUT": True | ||
} | ||
with override_settings(**settings): | ||
mocked_output_stream = MagicMock() | ||
connection = SendgridBackend(stream=mocked_output_stream) | ||
msg = EmailMessage( | ||
subject="Hello, World!", | ||
body="Hello, World!", | ||
from_email="Sam Smith <[email protected]>", | ||
to=["John Doe <[email protected]>"], | ||
connection=connection, | ||
) | ||
msg.send() | ||
self.assertTrue(mocked_output_stream.write.called) |
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