------------------------------------------------------------
revno: 1142
committer: Mark Sapiro <[email protected]>
branch nick: 2.2
timestamp: Tue 2011-01-25 16:52:57 -0800
message:
  Added one and changed two MimeDel tests for rev 1139 changes.
modified:
  tests/test_handlers.py


--
lp:mailman/2.2
https://code.launchpad.net/~mailman-coders/mailman/2.2

Your team Mailman Checkins is subscribed to branch lp:mailman/2.2.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/2.2/+edit-subscription
=== modified file 'tests/test_handlers.py'
--- tests/test_handlers.py	2010-07-11 17:16:50 +0000
+++ tests/test_handlers.py	2011-01-26 00:52:57 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2010 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2011 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -1139,6 +1139,7 @@
         self._mlist.filter_mime_types = ['image/jpeg']
         self._mlist.pass_mime_types = []
         self._mlist.convert_html_to_plaintext = 1
+        self._mlist.collapse_alternatives = 1
 
     def test_outer_matches(self):
         msg = email.message_from_string("""\
@@ -1172,10 +1173,9 @@
 --BOUNDARY--
 """)
         MimeDel.process(self._mlist, msg, {})
-        eq(len(msg.get_payload()), 1)
-        subpart = msg.get_payload(0)
-        eq(subpart.get_content_type(), 'image/gif')
-        eq(subpart.get_payload(), 'yyy')
+        self.assertTrue(not msg.is_multipart())
+        eq(msg.get_content_type(), 'image/gif')
+        eq(msg.get_payload(), 'yyy')
 
     def test_collapse_multipart_alternative(self):
         eq = self.assertEqual
@@ -1204,11 +1204,9 @@
 --BOUNDARY--
 """)
         MimeDel.process(self._mlist, msg, {})
-        eq(len(msg.get_payload()), 1)
-        eq(msg.get_content_type(), 'multipart/mixed')
-        subpart = msg.get_payload(0)
-        eq(subpart.get_content_type(), 'image/gif')
-        eq(subpart.get_payload(), 'yyy')
+        self.assertTrue(not msg.is_multipart())
+        eq(msg.get_content_type(), 'image/gif')
+        eq(msg.get_payload(), 'yyy')
 
     def test_convert_to_plaintext(self):
         # BAW: This test is dependent on your particular lynx version
@@ -1301,6 +1299,70 @@
         eq(msg.get_content_type(), 'text/plain')
         eq(msg.get_payload(), 'This is plain text')
 
+    def test_recast_multipart(self):
+        eq = self.assertEqual
+        self._mlist.filter_mime_types.append('application/pdf')
+        msg = email.message_from_string("""\
+From: [email protected]
+MIME-Version: 1.0
+Content-type: multipart/mixed;
+ boundary="Boundary_0"
+
+--Boundary_0
+Content-Type: multipart/mixed;
+ boundary="Boundary_1"
+
+--Boundary_1
+Content-type: multipart/mixed;
+ boundary="Boundary_2"
+
+--Boundary_2
+Content-type: multipart/alternative;
+ boundary="Boundary_3"
+
+--Boundary_3
+Content-type: text/plain; charset=us-ascii
+Content-transfer-encoding: 7BIT
+
+Plain text part
+--Boundary_3
+Content-type: text/html; charset=us-ascii
+Content-transfer-encoding: 7BIT
+
+HTML part
+--Boundary_3--
+
+
+--Boundary_2
+Content-type: application/pdf
+Content-transfer-encoding: 7BIT
+
+PDF part inner 2
+--Boundary_2--
+--Boundary_1
+Content-type: text/plain; charset=us-ascii
+Content-transfer-encoding: 7BIT
+
+second text
+--Boundary_1--
+
+--Boundary_0
+Content-Type: application/pdf
+Content-transfer-encoding: 7BIT
+
+PDF part outer
+--Boundary_0--
+""")
+        MimeDel.process(self._mlist, msg, {})
+        payload = msg.get_payload()
+        eq(len(payload), 2)
+        part1 = msg.get_payload(0)
+        eq(part1.get_content_type(), 'text/plain')
+        eq(part1.get_payload(), 'Plain text part')
+        part2 = msg.get_payload(1)
+        eq(part2.get_content_type(), 'text/plain')
+        eq(part2.get_payload(), 'second text')
+
 
 
 class TestModerate(TestBase):

_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to