summaryrefslogtreecommitdiff
path: root/service/test/unit
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-03-17 13:53:40 +0100
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-03-17 13:53:40 +0100
commit67beba06bc4a3d0ebac358eb59c9987c02d21bac (patch)
tree7d109ff5aa0586677b1433882ccd6e265ed49bec /service/test/unit
parente9a675d925778ef3ec6c38e235a71b25c1e3b344 (diff)
Don't fail to parse mail if neither Date nor Received header is avail.
- Issue #331
Diffstat (limited to 'service/test/unit')
-rw-r--r--service/test/unit/adapter/test_mail.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/service/test/unit/adapter/test_mail.py b/service/test/unit/adapter/test_mail.py
index 317db5de..5bb46687 100644
--- a/service/test/unit/adapter/test_mail.py
+++ b/service/test/unit/adapter/test_mail.py
@@ -31,6 +31,9 @@ class TestPixelatedMail(unittest.TestCase):
def setUp(self):
self.querier = mock()
+ def tearDown(self):
+ unstub()
+
def test_parse_date_from_soledad_uses_date_header_if_available(self):
leap_mail_date = 'Wed, 3 Sep 2014 12:36:17 -0300'
leap_mail_date_in_iso_format = "2014-09-03T12:36:17-03:00"
@@ -52,6 +55,17 @@ class TestPixelatedMail(unittest.TestCase):
self.assertEqual(str(mail.headers['Date']), leap_mail_date_in_iso_format)
+ def test_parse_date_from_soledad_fallback_to_now_if_neither_date_nor_received_header(self):
+ leap_mail_date_in_iso_format = "2014-09-03T13:11:15-03:00"
+
+ when(pixelated.support.date).iso_now().thenReturn(leap_mail_date_in_iso_format)
+ fdoc, hdoc, bdoc = test_helper.leap_mail()
+ del hdoc.content['date']
+
+ mail = PixelatedMail.from_soledad(fdoc, hdoc, bdoc, soledad_querier=self.querier)
+
+ self.assertEqual(str(mail.headers['Date']), leap_mail_date_in_iso_format)
+
def test_update_tags_return_a_set_with_the_current_tags(self):
soledad_docs = test_helper.leap_mail(extra_headers={'X-tags': '["custom_1", "custom_2"]'})
pixelated_mail = PixelatedMail.from_soledad(*soledad_docs, soledad_querier=self.querier)