-
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 SENDGRID_HOST_URL setting to fix #129 * Bump mypy and add type check to fix issue * Remove unused import from test * Set mypy to 1.4.1 * Add https:// to API url * Add seperate TESTING_SENDGRID_EU_API_KEY for testing EU sub accounts * Pass EU settings var to workflow * Update tox config to pass TESTING_SENDGRID_EU_API_KEY to envs --------- Co-authored-by: Steven Sklar <[email protected]>
- Loading branch information
1 parent
b7f11f9
commit bcfa80e
Showing
6 changed files
with
54 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
Header, | ||
MailSettings, | ||
Personalization, | ||
SpamCheck, | ||
Substitution, | ||
TrackingSettings, | ||
) | ||
|
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ class TestPostToSendgrid(SimpleTestCase): | |
) | ||
def test_post(self): | ||
""" | ||
Sends a POST to sendgrid's live API using a private API key that is stored | ||
Sends a POST to SendGrid's live API using a private API key that is stored | ||
in github. | ||
""" | ||
|
||
|
@@ -35,3 +35,34 @@ def test_post(self): | |
) | ||
val = msg.send() | ||
self.assertEqual(val, 1) | ||
|
||
# TESTING_SENDGRID_EU_API_KEY is only used for testing. | ||
@pytest.mark.skipif( | ||
not os.environ.get("TESTING_SENDGRID_EU_API_KEY"), | ||
reason="requires TESTING_SENDGRID_EU_API_KEY env var", | ||
) | ||
def test_eu_post(self): | ||
""" | ||
Sends a POST to SendGrid's live EU API using a private API key that is stored | ||
in GitHub. | ||
""" | ||
|
||
SENDGRID_API_KEY = os.environ.get("TESTING_SENDGRID_EU_API_KEY") | ||
|
||
# Set DEBUG=True so sandbox mode is enabled | ||
settings = { | ||
"DEBUG": True, | ||
"SENDGRID_API_KEY": SENDGRID_API_KEY, | ||
"SENDGRID_HOST_URL": "https://api.eu.sendgrid.com", | ||
"EMAIL_BACKEND": "sendgrid_backend.SendgridBackend", | ||
} | ||
|
||
with override_settings(**settings): | ||
msg = EmailMessage( | ||
subject="Hello, World!", | ||
body="Hello, World!", | ||
from_email="Sam Smith <[email protected]>", | ||
to=["John Doe <[email protected]>"], | ||
) | ||
val = msg.send() | ||
self.assertEqual(val, 1) |