summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2015-08-24 20:04:36 -0300
committerVictor Shyba <victor.shyba@gmail.com>2015-08-24 20:04:36 -0300
commitb1657f962dd56401d4ba1de1a8a752790765fab2 (patch)
tree00d85c9438bf8fcd52f8d087929a544b560fb082 /service/test
parentbfbd8446189d39b2824a90cc01e944812ec8d9fa (diff)
[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.
Diffstat (limited to 'service/test')
-rw-r--r--service/test/unit/adapter/mailstore/test_leap_mailstore.py17
1 files changed, 17 insertions, 0 deletions
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:]