From b1657f962dd56401d4ba1de1a8a752790765fab2 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Mon, 24 Aug 2015 20:04:36 -0300 Subject: [test] add case for nested attachments This is possible and just dicovered it sending 2 attachments + signature using Thunderbird. This test cover the new case. --- .../test/unit/adapter/mailstore/test_leap_mailstore.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'service/test/unit') diff --git a/service/test/unit/adapter/mailstore/test_leap_mailstore.py b/service/test/unit/adapter/mailstore/test_leap_mailstore.py index c2ad2d5a..79b672bc 100644 --- a/service/test/unit/adapter/mailstore/test_leap_mailstore.py +++ b/service/test/unit/adapter/mailstore/test_leap_mailstore.py @@ -308,6 +308,23 @@ class TestLeapMailStore(TestCase): expected = [{'ident': self._cdoc_phash_from_message(mocked_message, 2), 'name': 'filename.txt', 'encoding': 'base64'}] self.assertEqual(expected, message.as_dict()['attachments']) + @defer.inlineCallbacks + def test_add_mail_with_nested_attachments(self): + input_mail = MIMEMultipart() + input_mail.attach(MIMEText(u'a utf8 message', _charset='utf-8')) + attachment = MIMEApplication('pretend to be binary attachment data') + attachment.add_header('Content-Disposition', 'attachment', filename='filename.txt') + nested_attachment = MIMEMultipart() + nested_attachment.attach(attachment) + input_mail.attach(nested_attachment) + mocked_message = self._add_create_mail_mocks_to_soledad(input_mail) + store = LeapMailStore(self.soledad) + + message = yield store.add_mail('INBOX', input_mail.as_string()) + + expected = [{'ident': self._cdoc_phash_from_message(mocked_message, 2), 'name': 'filename.txt', 'encoding': 'base64'}] + self.assertEqual(expected, message.as_dict()['attachments']) + def _cdoc_phash_from_message(self, mocked_message, attachment_nr): return mocked_message.get_wrapper().cdocs[attachment_nr].future_doc_id[2:] -- cgit v1.2.3