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 | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/service/pixelated/adapter/soledad_querier.py b/service/pixelated/adapter/soledad_querier.py index 2ccbcd72..4123c71d 100644 --- a/service/pixelated/adapter/soledad_querier.py +++ b/service/pixelated/adapter/soledad_querier.py @@ -123,7 +123,7 @@ class SoledadQuerier: for part_key in hdoc['part_map'].keys(): self._extract_parts(hdoc['part_map'][part_key], parts) else: - headers_dict = {elem[0]: elem[1] for elem in hdoc['headers']} + headers_dict = {elem[0]: elem[1] for elem in hdoc.get('headers', [])} if 'attachment' in headers_dict.get('Content-Disposition', ''): parts['attachments'].append(self._extract_attachment(hdoc, headers_dict)) else: diff --git a/service/test/unit/adapter/soledad_querier_test.py b/service/test/unit/adapter/soledad_querier_test.py index 87ed5512..c63a3962 100644 --- a/service/test/unit/adapter/soledad_querier_test.py +++ b/service/test/unit/adapter/soledad_querier_test.py @@ -52,3 +52,15 @@ class SoledadQuerierTest(unittest.TestCase): self.assertIn('headers', attachment) self.assertIn('ident', attachment) self.assertIn('name', attachment) + + def test_extract_part_without_headers(self): + soledad = mock() + bdoc = mock() + bdoc.content = {'raw': 'esse papo seu ta qualquer coisa'} + when(soledad).get_from_index('by-type-and-payloadhash', 'cnt', any(unicode)).thenReturn([bdoc]) + hdoc = {'multi': True, 'part_map': {'1': {'multi': False, 'phash': u'0400BEBACAFE'}}} + querier = SoledadQuerier(soledad) + + parts = querier._extract_parts(hdoc) + + self.assertEquals(bdoc.content['raw'], parts['alternatives'][0]['content']) |