summaryrefslogtreecommitdiff
path: root/service/test/unit/adapter/test_mail.py
diff options
context:
space:
mode:
authorLisa Junger <ljunger@thoughtworks.com>2015-04-02 14:29:44 +0200
committerLisa Junger <ljunger@thoughtworks.com>2015-04-02 17:54:22 +0200
commit98ec21fedd2b27c6f28be993006380446f6b4abe (patch)
tree9fc14286c1a7a2e93cc26e5338a2d558a97dad93 /service/test/unit/adapter/test_mail.py
parentf11d9b2811373de173f0e02ec334c85e46571172 (diff)
catch invalid data in received header when parsing date.
- Issue #347
Diffstat (limited to 'service/test/unit/adapter/test_mail.py')
-rw-r--r--service/test/unit/adapter/test_mail.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/service/test/unit/adapter/test_mail.py b/service/test/unit/adapter/test_mail.py
index dc683bb6..d77816cd 100644
--- a/service/test/unit/adapter/test_mail.py
+++ b/service/test/unit/adapter/test_mail.py
@@ -68,16 +68,27 @@ class TestPixelatedMail(unittest.TestCase):
self.assertEqual(str(mail.headers['Date']), leap_mail_date_in_iso_format)
def test_use_datetime_now_as_fallback_for_invalid_date(self):
- leap_mail_date = 'söme däte'
+ leap_mail_date = u'söme däte'
date_expected = "2014-09-03T13:11:15-03:00"
- when(pixelated.support.date).iso_now().thenReturn(date_expected)
+ when(pixelated.support.date).iso_now().thenReturn(date_expected)
leap_mail = test_helper.leap_mail(headers={'date': leap_mail_date})
mail = PixelatedMail.from_soledad(*leap_mail, soledad_querier=self.querier)
self.assertEqual(str(mail.headers['Date']), date_expected)
+ def test_fall_back_to_ascii_if_invalid_received_header(self):
+ leap_mail_received_header = u"söme invalid received heäder\n"
+ date_expected = "2014-09-03T13:11:15-03:00"
+
+ when(pixelated.support.date).iso_now().thenReturn(date_expected)
+ leap_mail = test_helper.leap_mail(headers={'received': leap_mail_received_header})
+
+ mail = PixelatedMail.from_soledad(*leap_mail, soledad_querier=self.querier)
+
+ self.assertEqual(mail.headers['Date'], date_expected)
+
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)