summaryrefslogtreecommitdiff
path: root/tests/db
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-08-23 09:08:39 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-08-28 15:07:15 -0700
commite16e846db354e5775c69891c2b58b12e110f79b8 (patch)
treede4fee956a5b0cd3ded4e1591f2cd925155d4535 /tests/db
parent599dfa61c82c3192c6ac9ef59a8950225e4575d0 (diff)
tests/db/utils: Add tests for message_from_string
Diffstat (limited to 'tests/db')
-rw-r--r--tests/db/utils_test.py18
1 files changed, 18 insertions, 0 deletions
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 = '<!DOCTYPE html><html><body>This is an html email</body></html>'
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')