-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix amazon_ses inbound email ESP provider #3509
Changes from 4 commits
d0d0f4e
c71b9b7
257f7d0
cca8791
2226a1e
7922987
23326ee
3ddd51c
7ecd524
ade51db
c7c2e14
ee5483d
ecc3600
fd430e7
7b68ef4
839620e
f5c636a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest, anymail | ||
from apps.email.inbound import InboundEmailWebhookView | ||
from django.test.client import RequestFactory | ||
|
||
@pytest.mark.django_db | ||
def test_amazon_ses_provider_load( | ||
settings | ||
): | ||
result = False | ||
|
||
settings.INBOUND_EMAIL_ESP = "amazon_ses" | ||
rf = RequestFactory() | ||
|
||
inbound_view = InboundEmailWebhookView() | ||
try: | ||
inbound_view.post(rf.post('/fake-mock-location')) | ||
result = True | ||
except anymail.exceptions.AnymailAPIError: | ||
# We don't test anymail, but it's invocation ability | ||
result = True | ||
assert result | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on an aside, if you would like to assert that an exception is raised, you can do something like this 🙂 with pytest.raises(anymail.exceptions.AnymailAPIError):
inbound_view.post(rf.post('/fake-mock-location')) From the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback! I think now it looks better😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest looking into the
rest_framework.test.APIClient
instead here (we have many examples throughout the tests in the codebase).With
APIClient
you will actually be invoking thepost
handler that raises the exception according to the stack trace in the issue description in #3508