-
Notifications
You must be signed in to change notification settings - Fork 139
Description
So I've been using anymail for a while to send emails but now I've started work on tracking emails and I'm running into some issues around testing. The issue at the moment is that I've got lots of places in the code that read:
msg = self.generate_email()
msg.send()
email_sent = self.create_sent_object(email_id=msg.message_id)
Where generate_email is creating an EmailMultiAlternatives object. This is failing in tests because msg.message_id isn't working in tests. Presumably this is because Django is switching the email backend out on tests so they don't actually get sent. Based off what I've seen in this packages tests I've tried:
@override_settings(EMAIL_BACKEND='anymail.backends.test.TestBackend', ANYMAIL_TEST_SAMPLE_SETTING='sample',)
But that doesn't seem to be helping at all, also I have no idea what ANYMAIL_TEST_SAMPLE_SETTING is doing so 'sample' might be wrong. I can't seem to find anything in the docs covering what to do in this situation. Happy to write it up into the docs once I've got it working as it might be useful for other people.