diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2015-01-15 21:21:03 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2022-11-04 13:35:39 +0100 |
commit | cf30b2ccefcf5cb1afdd65b9c462b64992af9ea6 (patch) | |
tree | a4749e65899a43b246d61abdba19526d02071a24 | |
parent | 61bf7164a30ee0a03256fd3c9a72460dd3d690ea (diff) | |
download | pyg-cf30b2ccefcf5cb1afdd65b9c462b64992af9ea6.tar.gz |
Setup testing of the real emails
-rw-r--r-- | test/test_parse_received.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/test_parse_received.py b/test/test_parse_received.py index 8fa1945..75d16f4 100644 --- a/test/test_parse_received.py +++ b/test/test_parse_received.py @@ -1,4 +1,5 @@ import datetime +import logging import email import unittest @@ -8,7 +9,7 @@ from rply import Token import parse_received -#logging.basicConfig(level=logging.DEBUG) +logging.basicConfig(level=logging.DEBUG) INPUT_01 = \ @@ -143,13 +144,29 @@ class TestReceivedParser(unittest.TestCase): observed = parse_received.parse_header(INPUT_02) self.assertEqual(observed, expected) + +class TestEmailHeaderParser(unittest.TestCase): + maxDiff = None + def test_email_01(self): + with open('test/samples/testing-email-01.eml', 'r') as inmail: + msg = email.message_from_file(inmail) + received_hdrs = msg.get_all('Received') + expected = [] + parsed_headers = [] + for hdr in received_hdrs: + logging.debug('hdr:\n%s', hdr) + parsed_headers.append(parse_received.parse_header(hdr)) + self.assertEqual(parsed_headers, expected) + + def test_email_02(self): with open('examples/mail', 'r') as inmail: msg = email.message_from_file(inmail) received_hdrs = msg.get_all('Received') expected = [] parsed_headers = [] for hdr in received_hdrs: + logging.debug('hdr:\n%s', hdr) parsed_headers.append(parse_received.parse_header(hdr)) self.assertEqual(parsed_headers, expected) |