forked from mirror/django-mailbox
Added test django_mailbox.tests.test_process_email.TestProcessEmail.test_message_reply
This commit is contained in:
parent
24138d1dc7
commit
552e033655
2 changed files with 32 additions and 1 deletions
|
|
@ -19,6 +19,7 @@ def get_email_as_text(name):
|
|||
) as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
class EmailMessageTestCase(TestCase):
|
||||
ALLOWED_EXTRA_HEADERS = [
|
||||
'MIME-Version',
|
||||
|
|
@ -30,7 +31,7 @@ class EmailMessageTestCase(TestCase):
|
|||
self._STRIP_UNALLOWED_MIMETYPES = models.STRIP_UNALLOWED_MIMETYPES
|
||||
self._TEXT_STORED_MIMETYPES = models.TEXT_STORED_MIMETYPES
|
||||
|
||||
self.mailbox = Mailbox.objects.create()
|
||||
self.mailbox = Mailbox.objects.create(from_email='from@example.com')
|
||||
super(EmailMessageTestCase, self).setUp()
|
||||
|
||||
def _get_email_as_text(self, name):
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import six
|
|||
|
||||
from django_mailbox.models import Mailbox, Message
|
||||
from django_mailbox.tests.base import EmailMessageTestCase
|
||||
from django.core.mail import EmailMessage
|
||||
|
||||
|
||||
__all__ = ['TestProcessEmail']
|
||||
|
|
@ -200,3 +201,32 @@ class TestProcessEmail(EmailMessageTestCase):
|
|||
actual_from = msg.from_header
|
||||
|
||||
self.assertEqual(expected_from, actual_from)
|
||||
|
||||
def test_message_reply(self):
|
||||
email_object = EmailMessage('Test subject', # subject
|
||||
'Test body', # body
|
||||
'username@example.com', # from
|
||||
['mr.test32@mail.ru'], # to
|
||||
)
|
||||
msg = self.mailbox.record_outgoing_message(email_object.message())
|
||||
|
||||
self.assertEqual(msg.outgoing, True)
|
||||
|
||||
actual_from = 'username@example.com'
|
||||
reply_email_object = EmailMessage('Test subject', # subject
|
||||
'Test body', # body
|
||||
actual_from, # from
|
||||
['mr.test32@mail.ru'], # to
|
||||
)
|
||||
|
||||
reply_msg = msg.reply(reply_email_object)
|
||||
|
||||
self.assertEqual(reply_msg.in_reply_to, msg)
|
||||
|
||||
self.assertEqual(actual_from, msg.from_header)
|
||||
|
||||
reply_email_object.from_email = None
|
||||
|
||||
second_reply_msg = msg.reply(reply_email_object)
|
||||
|
||||
self.assertEqual(self.mailbox.from_email, second_reply_msg.from_header)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue