diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/adapter/soledad_querier.py | 2 | ||||
-rw-r--r-- | service/test/unit/adapter/soledad_querier_test.py | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/service/pixelated/adapter/soledad_querier.py b/service/pixelated/adapter/soledad_querier.py index aa49d3b4..e36f2e1a 100644 --- a/service/pixelated/adapter/soledad_querier.py +++ b/service/pixelated/adapter/soledad_querier.py @@ -136,7 +136,7 @@ class SoledadQuerier: parts = {'alternatives': [], 'attachments': []} if hdoc['multi']: - for part_key in hdoc['part_map'].keys(): + for part_key in hdoc.get('part_map', {}).keys(): self._extract_parts(hdoc['part_map'][part_key], parts) else: headers_dict = {elem[0]: elem[1] for elem in hdoc.get('headers', [])} diff --git a/service/test/unit/adapter/soledad_querier_test.py b/service/test/unit/adapter/soledad_querier_test.py index 84f2bd5e..d07fdb00 100644 --- a/service/test/unit/adapter/soledad_querier_test.py +++ b/service/test/unit/adapter/soledad_querier_test.py @@ -67,6 +67,21 @@ class SoledadQuerierTest(unittest.TestCase): self.assertEquals(bdoc.content['raw'], parts['alternatives'][0]['content']) + def test_extract_handles_missing_part_map(self): + soledad = mock() + hdoc = {u'multi': True, + u'ctype': u'message/delivery-status', + u'headers': [[u'Content-Description', u'Delivery report'], [u'Content-Type', u'message/delivery-status']], + u'parts': 2, + u'phash': None, + u'size': 554} + querier = SoledadQuerier(soledad) + + parts = querier._extract_parts(hdoc) + + self.assertEquals(0, len(parts['alternatives'])) + self.assertEquals(0, len(parts['attachments'])) + def test_attachment_base64(self): soledad = mock() bdoc = mock() |