Permalink
Browse files

coverage

  • Loading branch information...
1 parent 04dd01c commit 08f537441243a5baa882daa7c6f49a84c371d5f7 @mcdonc mcdonc committed Mar 20, 2012
Showing with 36 additions and 0 deletions.
  1. +36 −0 pyramid_mailer/tests.py
View
@@ -971,6 +971,42 @@ def test___repr__(self):
result,
"<MIMEPart 'html/text': 'text/html', None, multipart=False>")
+ def test_extract_payload_text_type(self):
+ part = self._makeOne('text/html')
+ L = []
+ part.set_payload = lambda body: L.append(body)
+ mail = DummyMail('body')
+ part.extract_payload(mail)
+ self.assertEqual(L, ['body'])
+
+ def test_extract_payload_non_text_type_no_cdisp(self):
+ part = self._makeOne('text/html')
+ L = []
+ part.set_payload = lambda body: L.append(body)
+ mail = DummyMail('body', 'application/octet-stream')
+ part.extract_payload(mail)
+ self.assertEqual(L, ['body'])
+
+ def test_extract_payload_non_text_type_with_cdisp(self):
+ part = self._makeOne('text/html')
+ L = []
+ part.set_payload = lambda body: L.append(body)
+ part.add_header = lambda h, d, **x: L.append((h, d, x))
+ mail = DummyMail('body', 'application/octet-stream', 'foo')
+ part.extract_payload(mail)
+ self.assertEqual(L, [('Content-Disposition', 'foo', {}), 'body'])
+
+class DummyMail(object):
+ def __init__(self, body, content_type='text/plain',
+ content_disposition=None):
+ self.body = body
+ self.content_type = content_type
+ self.content_disposition = content_disposition
+
+ @property
+ def content_encoding(self):
+ return {'Content-Type':(self.content_type, {}),
+ 'Content-Disposition':(self.content_disposition, {})}
class Dummy(object):
pass

0 comments on commit 08f5374

Please sign in to comment.