-
Notifications
You must be signed in to change notification settings - Fork 291
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
Conversation
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.
thanks for your contribution @Lutseslav! 🙏
do you mind adding a test which asserts that the Amazon SES provider works?
Deal. Shall I put assertion in that location? Which file is the most suitable for that or I'll create the new one with deps assertions? |
@Lutseslav I would suggest adding it here as an integration test that uses the API endpoint which you reported the issue on in #3508. Does that make sense? |
|
@joeyorlando I've made some kind of amazon_ses checking😅 Hopefully, it's plausible. |
result = False | ||
|
||
settings.INBOUND_EMAIL_ESP = "amazon_ses" | ||
rf = RequestFactory() |
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 the post
handler that raises the exception according to the stack trace in the issue description in #3508
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 comment
The 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 pytest
docs:
Assert that a code block/function call raises expected_exception or raise a failure exception otherwise.
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.
Thanks for the feedback! I think now it looks better😅
We might also need to label PR with |
@joeyorlando Take a look please - all the receive flow is now expected to return 200. |
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.
@Lutseslav thanks for your patience with the feedback on the test. LGTM 🙏
What this PR does
Fixes django-anymail[amazon-ses] issues according to anymail docs
Which issue(s) this PR fixes
#3508
Checklist
pr:no public docs
PR label added if not required)CHANGELOG.md
updated (orpr:no changelog
PR label added if not required)