summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-09-03 16:11:44 -0300
committerDuda Dornelles <ddornell@thoughtworks.com>2014-09-03 16:11:44 -0300
commite71ff5d379a5d764df60d0675a1f130d46f4318a (patch)
tree1a88f3289f0b5d3e970d0378fb2bb0f2040cd141 /service/test
parent3bd6b15a18d5fc89506fb40becd7ad7b7449d7da (diff)
falling back to received header for date if email doesnt have date header
Diffstat (limited to 'service/test')
-rw-r--r--service/test/adapter/pixelated_mail_test.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/service/test/adapter/pixelated_mail_test.py b/service/test/adapter/pixelated_mail_test.py
index e0b9a662..c9146f24 100644
--- a/service/test/adapter/pixelated_mail_test.py
+++ b/service/test/adapter/pixelated_mail_test.py
@@ -33,6 +33,27 @@ class TestPixelatedMail(unittest.TestCase):
'tags': ['sent']
}
+ def test_parse_date_from_leap_mail_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-03 12:36:17-03:00"
+
+ leap_mail = test_helper.leap_mail(headers={'date': leap_mail_date})
+
+ mail = PixelatedMail.from_leap_mail(leap_mail)
+
+ self.assertEqual(str(mail.date), leap_mail_date_in_iso_format)
+
+ def test_parse_date_from_leap_mail_fallback_to_received_header_if_date_header_isnt_available(self):
+ leap_mail_date = "Wed, 03 Sep 2014 13:11:15 -0300"
+ leap_mail_date_in_iso_format = "2014-09-03 13:11:15-03:00"
+ leap_mail_received_header = "by bitmask.local from 127.0.0.1 with ESMTP ;\n " + leap_mail_date
+
+ leap_mail = test_helper.leap_mail(headers={'received': leap_mail_received_header})
+
+ mail = PixelatedMail.from_leap_mail(leap_mail)
+
+ self.assertEqual(str(mail.date), leap_mail_date_in_iso_format)
+
def test_leap_recent_flag_is_translated_to_inbox_tag(self):
pixelated_mail = PixelatedMail.from_leap_mail(test_helper.leap_mail(leap_flags=['\\Recent']))
self.assertIn(Tag('inbox'), pixelated_mail.tags)
@@ -59,7 +80,6 @@ class TestPixelatedMail(unittest.TestCase):
self.assertEquals(set([Tag('custom_tag'), Tag('inbox')]), pixelated_mail.tags)
def test_from_dict(self):
-
mail = PixelatedMail.from_dict(self.mail_dict)
self.assertEqual(mail.headers['cc'], ['cc@pixelated.org', 'anothercc@pixelated.org'])