From e16e846db354e5775c69891c2b58b12e110f79b8 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 23 Aug 2017 09:08:39 -0700 Subject: tests/db/utils: Add tests for message_from_string --- tests/db/utils_test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests') diff --git a/tests/db/utils_test.py b/tests/db/utils_test.py index 03db8500..3e7ef9d3 100644 --- a/tests/db/utils_test.py +++ b/tests/db/utils_test.py @@ -771,3 +771,21 @@ class TestExtractBody(unittest.TestCase): expected = 'This is an html email' self.assertEqual(actual, expected) + + +class TestMessageFromString(unittest.TestCase): + + """Tests for message_from_string. + + Because the implementation is that this is a wrapper around + message_from_file, it's not important to have a large swath of tests, just + enough to show that things are being passed correctly. + """ + + def test(self): + m = email.mime.text.MIMEText(u'This is some text', 'plain', 'utf-8') + m['Subject'] = 'test' + m['From'] = 'me' + m['To'] = 'Nobody' + message = utils.message_from_string(m.as_string()) + self.assertEqual(message.get_payload(), 'This is some text') -- cgit v1.2.3