Moto: Feature request: Make it easier to assert against sent SES emails

Created on 11 Dec 2017  路  3Comments  路  Source: spulec/moto

As a feature request, it would be nice if the Mock SES backend kept the actual email content in the sent_messages list, and made it easy to make assertions against them.

I think two things would be needed:

  • The Message class would have to capture actual content of the emails.

  • The backend would have to expose those messages somehow so test code could assert against them.

I'm imagining something like

with fake_ses() as mock_ses:
    ... # tests that trigger sending email
    assert '[email protected]' in mock_ses.sent_messages[0].recipients

Most helpful comment

@bjmc The SES backend state is available on the SES module, e.g:

from boto.ses import ses_backend
assert ses_backend.sent_messages[0]

For future readers, ses_backend is available on moto not boto:

from moto.ses import ses_backend
#    ^^^^
assert ses_backend.sent_messages[0]

All 3 comments

@bjmc The SES backend state is available on the SES module, e.g:

from boto.ses import ses_backend
assert ses_backend.sent_messages[0]

Going to close this. @r1b 's suggestion is our current best practice.

@bjmc The SES backend state is available on the SES module, e.g:

from boto.ses import ses_backend
assert ses_backend.sent_messages[0]

For future readers, ses_backend is available on moto not boto:

from moto.ses import ses_backend
#    ^^^^
assert ses_backend.sent_messages[0]
Was this page helpful?
0 / 5 - 0 ratings