Skip to content
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

Build unsaved Message from email.message.Message using public API (for unit testing of dependent code) #194

Open
stevecj opened this issue Oct 26, 2018 · 2 comments

Comments

@stevecj
Copy link

stevecj commented Oct 26, 2018

It would be nice if there was a sanctioned way to build an unsaved Message model instance from an email.message.Message object via the public API of django-mailbox. Using a function of a services module, perhaps?

The purpose of this would be for faster testing of code that deals with Message instances in the form that they would be constructed from particular raw messages.

@ad-m
Copy link
Collaborator

ad-m commented Oct 29, 2018

I understand your need. At that moment there is no way for that (Pull requests are welcome). See

incoming_email_object = self._get_email_object(
'message_with_many_multiparts.eml',
)
# Note: this is identical to the above, but it appears that
# while reading-in an e-mail message, we do alter it slightly
expected_email_object = self._get_email_object(
'message_with_many_multiparts.eml',
)
models.TEXT_STORED_MIMETYPES = ['text/plain']
msg = self.mailbox.process_incoming_message(incoming_email_object)
actual_email_object = msg.get_email_object()
self.assertEqual(
actual_email_object,
expected_email_object,
)
how to tests mail messages parsing (so far).

@pfouque
Copy link
Collaborator

pfouque commented Dec 23, 2023

I guess factoryboy is what you're looking for.
Tests execution time is not a topic at the moment, but feel free to build a pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants