Skip to content

Commit

Permalink
Merge pull request #2503 from Andrew-Chen-Wang/master
Browse files Browse the repository at this point in the history
Add unsupported mail_service combinations
  • Loading branch information
browniebroke authored Mar 22, 2020
2 parents b5f2e16 + 484fa4a commit 5dcfebd
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 19 deletions.
14 changes: 7 additions & 7 deletions docs/project-generation-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ cloud_provider:
mail_service:
Select an email service that Django-Anymail provides

1. Amazon SES_
2. Mailgun_
1. Mailgun_
2. `Amazon SES`_
3. Mailjet_
4. Mandrill_
5. Postmark_
6. SendGrid_
7. SendinBlue_
8. SparkPost_
9. Plain/Vanilla Django-Anymail_
9. `Other SMTP`_

use_drf:
Indicates whether the project should be configured to use `Django Rest Framework`_.
Expand Down Expand Up @@ -114,8 +114,8 @@ ci_tool:
Select a CI tool for running tests. The choices are:

1. None
2. Travis_
3. Gitlab_
2. `Travis CI`_
3. `Gitlab CI`_

keep_local_envs_in_vcs:
Indicates whether the project's ``.envs/.local/`` should be kept in VCS
Expand Down Expand Up @@ -145,15 +145,15 @@ debug:
.. _AWS: https://aws.amazon.com/s3/
.. _GCP: https://cloud.google.com/storage/

.. _SES: https://aws.amazon.com/ses/
.. _Amazon SES: https://aws.amazon.com/ses/
.. _Mailgun: https://www.mailgun.com
.. _Mailjet: https://www.mailjet.com
.. _Mandrill: http://mandrill.com
.. _Postmark: https://postmarkapp.com
.. _SendGrid: https://sendgrid.com
.. _SendinBlue: https://www.sendinblue.com
.. _SparkPost: https://www.sparkpost.com
.. _Django-Anymail: https://anymail.readthedocs.io/en/stable/
.. _Other SMTP: https://anymail.readthedocs.io/en/stable/

.. _Django Rest Framework: https://github.com/encode/django-rest-framework/

Expand Down
12 changes: 12 additions & 0 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,15 @@
"You should either use Whitenoise or select a Cloud Provider to serve static files"
)
sys.exit(1)

if (
"{{ cookiecutter.cloud_provider }}" == "GCP"
and "{{ cookiecutter.mail_service }}" == "Amazon SES"
) or (
"{{ cookiecutter.cloud_provider }}" == "None"
and "{{ cookiecutter.mail_service }}" == "Amazon SES"
):
print(
"You should either use AWS or select a different Mail Service for sending emails."
)
sys.exit(1)
42 changes: 30 additions & 12 deletions tests/test_cookiecutter_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,33 @@ def context():
{"cloud_provider": "AWS", "use_whitenoise": "n"},
{"cloud_provider": "GCP", "use_whitenoise": "y"},
{"cloud_provider": "GCP", "use_whitenoise": "n"},
{"cloud_provider": "None", "use_whitenoise": "y"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Mailgun"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Mailjet"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Mandrill"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Postmark"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Sendgrid"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "SendinBlue"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "SparkPost"},
{"cloud_provider": "None", "use_whitenoise": "y", "mail_service": "Other SMTP"},
# Note: cloud_provider=None AND use_whitenoise=n is not supported
{"mail_service": "Mailgun"},
{"mail_service": "Amazon SES"},
{"mail_service": "Mailjet"},
{"mail_service": "Mandrill"},
{"mail_service": "Postmark"},
{"mail_service": "Sendgrid"},
{"mail_service": "SendinBlue"},
{"mail_service": "SparkPost"},
{"mail_service": "Other SMTP"},
{"cloud_provider": "AWS", "mail_service": "Mailgun"},
{"cloud_provider": "AWS", "mail_service": "Amazon SES"},
{"cloud_provider": "AWS", "mail_service": "Mailjet"},
{"cloud_provider": "AWS", "mail_service": "Mandrill"},
{"cloud_provider": "AWS", "mail_service": "Postmark"},
{"cloud_provider": "AWS", "mail_service": "Sendgrid"},
{"cloud_provider": "AWS", "mail_service": "SendinBlue"},
{"cloud_provider": "AWS", "mail_service": "SparkPost"},
{"cloud_provider": "AWS", "mail_service": "Other SMTP"},
{"cloud_provider": "GCP", "mail_service": "Mailgun"},
{"cloud_provider": "GCP", "mail_service": "Mailjet"},
{"cloud_provider": "GCP", "mail_service": "Mandrill"},
{"cloud_provider": "GCP", "mail_service": "Postmark"},
{"cloud_provider": "GCP", "mail_service": "Sendgrid"},
{"cloud_provider": "GCP", "mail_service": "SendinBlue"},
{"cloud_provider": "GCP", "mail_service": "SparkPost"},
{"cloud_provider": "GCP", "mail_service": "Other SMTP"},
# Note: cloud_providers GCP and None with mail_service Amazon SES is not supported
{"use_drf": "y"},
{"use_drf": "n"},
{"js_task_runner": "None"},
Expand Down Expand Up @@ -86,6 +102,8 @@ def context():

UNSUPPORTED_COMBINATIONS = [
{"cloud_provider": "None", "use_whitenoise": "n"},
{"cloud_provider": "GCP", "mail_service": "Amazon SES"},
{"cloud_provider": "None", "mail_service": "Amazon SES"},
]


Expand Down Expand Up @@ -163,7 +181,7 @@ def test_travis_invokes_pytest(cookies, context):

with open(f"{result.project}/.travis.yml", "r") as travis_yml:
try:
assert yaml.load(travis_yml)["script"] == ["pytest"]
assert yaml.load(travis_yml, Loader=yaml.FullLoader)["script"] == ["pytest"]
except yaml.YAMLError as e:
pytest.fail(e)

Expand All @@ -179,7 +197,7 @@ def test_gitlab_invokes_flake8_and_pytest(cookies, context):

with open(f"{result.project}/.gitlab-ci.yml", "r") as gitlab_yml:
try:
gitlab_config = yaml.load(gitlab_yml)
gitlab_config = yaml.load(gitlab_yml, Loader=yaml.FullLoader)
assert gitlab_config["flake8"]["script"] == ["flake8"]
assert gitlab_config["pytest"]["script"] == ["pytest"]
except yaml.YAMLError as e:
Expand Down

0 comments on commit 5dcfebd

Please sign in to comment.