Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #68 from matiboy/master
Allow API key to be passed in constructor
- Loading branch information
Showing
4 changed files
with
53 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
coverage | ||
pytest | ||
pytest-cov | ||
pytest-cov | ||
pytest-django | ||
Django | ||
sendgrid>=3.6.5,<4 |
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,21 @@ | ||
from sgbackend import SendGridBackend | ||
|
||
|
||
def test_read_from_settings_by_default(settings): | ||
"""API key should be read from settings if not provided in init.""" | ||
settings.SENDGRID_API_KEY = 'somerandom key' | ||
sg = SendGridBackend() | ||
|
||
assert sg.api_key == settings.SENDGRID_API_KEY | ||
|
||
|
||
def test_read_from_init_if_provided(settings): | ||
"""Should pick up API key from init, if provided.""" | ||
settings.SENDGRID_API_KEY = 'somerandom key' | ||
actual_key = 'another' | ||
|
||
sg = SendGridBackend(api_key=actual_key) | ||
|
||
assert sg.api_key == actual_key | ||
|
||
""" Note: no API key configuration is tested in test_mail.""" |