diff options
author | Patrick Maia <pmaia@thoughtworks.com> | 2014-10-29 11:00:12 -0300 |
---|---|---|
committer | Patrick Maia <pmaia@thoughtworks.com> | 2014-10-29 11:01:48 -0300 |
commit | f24dc09f8073748d5734c83617044b599a08d192 (patch) | |
tree | 8aaa791af0248b68442a3fb8255d15ea2c35b037 /service/test/unit/adapter | |
parent | 30d3d281d0f5d8598f4d36fde08f2b12da55f711 (diff) |
Card #30 - adds method to retrieve attachments from soledad
Diffstat (limited to 'service/test/unit/adapter')
-rw-r--r-- | service/test/unit/adapter/soledad_querier_test.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/service/test/unit/adapter/soledad_querier_test.py b/service/test/unit/adapter/soledad_querier_test.py index c63a3962..84f2bd5e 100644 --- a/service/test/unit/adapter/soledad_querier_test.py +++ b/service/test/unit/adapter/soledad_querier_test.py @@ -18,6 +18,8 @@ from pixelated.adapter.soledad_querier import SoledadQuerier from mockito import mock, when, any import json import os +import base64 +import quopri class SoledadQuerierTest(unittest.TestCase): @@ -64,3 +66,25 @@ class SoledadQuerierTest(unittest.TestCase): parts = querier._extract_parts(hdoc) self.assertEquals(bdoc.content['raw'], parts['alternatives'][0]['content']) + + def test_attachment_base64(self): + soledad = mock() + bdoc = mock() + bdoc.content = {'raw': base64.encodestring('esse papo seu ta qualquer coisa'), 'content-type': 'text/plain'} + when(soledad).get_from_index('by-type-and-payloadhash', 'cnt', any(unicode)).thenReturn([bdoc]) + querier = SoledadQuerier(soledad) + + attachment = querier.attachment(u'0400BEBACAFE', 'base64') + + self.assertEquals('esse papo seu ta qualquer coisa', attachment['content']) + + def test_attachment_quoted_printable(self): + soledad = mock() + bdoc = mock() + bdoc.content = {'raw': quopri.encodestring('esse papo seu ta qualquer coisa'), 'content-type': 'text/plain'} + when(soledad).get_from_index('by-type-and-payloadhash', 'cnt', any(unicode)).thenReturn([bdoc]) + querier = SoledadQuerier(soledad) + + attachment = querier.attachment(u'0400BEBACAFE', 'quoted-printable') + + self.assertEquals('esse papo seu ta qualquer coisa', attachment['content']) |