annotate test/test_multipart.py @ 7932:55229bfcdd8a

chore(ruff): cleanup setup.py whitespace, comprehensions etc. Fixes: replace [f for f in ...] with list(...) replace else block after return in if true case use with open() when reading announcement.txt add trailing , in lists. whitespace normalizing
author John Rouillard <rouilj@ieee.org>
date Sun, 05 May 2024 18:19:04 -0400
parents f8893e1cde0d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
1 #
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
3 # This module is free software, and you may redistribute it and/or modify
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
4 # under the same terms as Python, so long as this copyright message and
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
5 # disclaimer are retained in their original form.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
6 #
214
18134bffab37 stupid typo
Richard Jones <richard@users.sourceforge.net>
parents: 213
diff changeset
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
213
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
10 # POSSIBILITY OF SUCH DAMAGE.
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
11 #
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
d45384bc6420 Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents: 127
diff changeset
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
17
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
18 import email
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
19 import unittest
5418
55f09ca366c4 Python 3 preparation: StringIO.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5400
diff changeset
20 from roundup.anypy.strings import StringIO
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
21
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
22 from roundup.mailgw import RoundupMessage
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
23
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
24 def gen_message(spec):
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
25 """Create a basic MIME message according to 'spec'.
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
26
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
27 Each line of a spec has one content-type, which is optionally indented.
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
28 The indentation signifies how deep in the MIME hierarchy the
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
29 content-type is.
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
30
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
31 """
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
32
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
33 def getIndent(line):
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
34 """Get the current line's indentation, using four-space indents."""
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
35 count = 0
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
36 for char in line:
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
37 if char != ' ':
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
38 break
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
39 count += 1
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
40 return count // 4
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
41
4425
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
42 # A note on message/rfc822: The content of such an attachment is an
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
43 # email with at least one header line. RFC2046 tells us: """ A
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
44 # media type of "message/rfc822" indicates that the body contains an
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
45 # encapsulated message, with the syntax of an RFC 822 message.
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
46 # However, unlike top-level RFC 822 messages, the restriction that
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
47 # each "message/rfc822" body must include a "From", "Date", and at
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
48 # least one destination header is removed and replaced with the
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
49 # requirement that at least one of "From", "Subject", or "Date" must
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
50 # be present."""
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
51 # This means we have to add a newline after the mime-header before
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
52 # the subject, otherwise the subject is part of the mime header not
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
53 # part of the email header.
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
54 table = {'multipart/signed': ' boundary="boundary-%(indent)s";\n',
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
55 'multipart/mixed': ' boundary="boundary-%(indent)s";\n',
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
56 'multipart/alternative': ' boundary="boundary-%(indent)s";\n',
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
57 'text/plain': ' name="foo.txt"\nfoo\n',
5307
5b4931cfc182 Test entity code path in dehtml.
John Rouillard <rouilj@ieee.org>
parents: 5306
diff changeset
58 'text/html': ' name="bar.html"\n<html><body>bar &gt;</body></html>\n',
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
59 'application/pgp-signature': ' name="foo.gpg"\nfoo\n',
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
60 'application/pdf': ' name="foo.pdf"\nfoo\n',
4425
0bb3054274b8 - some formatting
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3915
diff changeset
61 'message/rfc822': '\nSubject: foo\n\nfoo\n'}
3915
6b3919328381 support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents: 1975
diff changeset
62
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
63 parts = []
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
64 for line in spec.splitlines():
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
65 content_type = line.strip()
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
66 if not content_type:
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
67 continue
3915
6b3919328381 support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents: 1975
diff changeset
68
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
69 indent = getIndent(line)
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
70 if indent:
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
71 parts.append('\n--boundary-%s\n' % indent)
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
72 parts.append('Content-type: %s;\n' % content_type)
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
73 parts.append(table[content_type] % {'indent': indent + 1})
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
74
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
75 for i in range(indent, 0, -1):
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
76 parts.append('\n--boundary-%s--\n' % i)
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
77
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
78 return email.message_from_file(StringIO(''.join(parts)), RoundupMessage)
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
79
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
80 class MultipartTestCase(unittest.TestCase):
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
81 def setUp(self):
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
82 self.fp = StringIO()
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
83 w = self.fp.write
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
84 w('Content-Type: multipart/mixed; boundary="foo"\r\n\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
85 w('This is a multipart message. Ignore this bit.\r\n')
3915
6b3919328381 support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents: 1975
diff changeset
86 w('\r\n--foo\r\n')
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
87
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
88 w('Content-Type: text/plain\r\n\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
89 w('Hello, world!\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
90 w('\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
91 w('Blah blah\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
92 w('foo\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
93 w('-foo\r\n')
3915
6b3919328381 support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents: 1975
diff changeset
94 w('\r\n--foo\r\n')
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
95
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
96 w('Content-Type: multipart/alternative; boundary="bar"\r\n\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
97 w('This is a multipart message. Ignore this bit.\r\n')
3915
6b3919328381 support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents: 1975
diff changeset
98 w('\r\n--bar\r\n')
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
99
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
100 w('Content-Type: text/plain\r\n\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
101 w('Hello, world!\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
102 w('\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
103 w('Blah blah\r\n')
3915
6b3919328381 support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents: 1975
diff changeset
104 w('\r\n--bar\r\n')
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
105
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
106 w('Content-Type: text/html\r\n\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
107 w('<b>Hello, world!</b>\r\n')
3915
6b3919328381 support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents: 1975
diff changeset
108 w('\r\n--bar--\r\n')
6b3919328381 support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents: 1975
diff changeset
109 w('\r\n--foo\r\n')
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
111 w('Content-Type: text/plain\r\n\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
112 w('Last bit\n')
3915
6b3919328381 support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents: 1975
diff changeset
113 w('\r\n--foo--\r\n')
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
114 self.fp.seek(0)
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
115
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
116 def testMultipart(self):
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
117 m = email.message_from_file(self.fp, RoundupMessage)
5649
f8893e1cde0d assert_ is depricated. Replacing with assertTrue to reduce logs in travisci.
John Rouillard <rouilj@ieee.org>
parents: 5547
diff changeset
118 self.assertTrue(m is not None)
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
119
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
120 it = iter(m.get_payload())
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
121
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
122 # first text/plain
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
123 p = next(it, None)
5649
f8893e1cde0d assert_ is depricated. Replacing with assertTrue to reduce logs in travisci.
John Rouillard <rouilj@ieee.org>
parents: 5547
diff changeset
124 self.assertTrue(p is not None)
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
125 self.assertEqual(p.get_content_type(), 'text/plain')
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
126 self.assertEqual(p.get_payload(),
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
127 'Hello, world!\r\n\r\nBlah blah\r\nfoo\r\n-foo\r\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
128
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
129 # sub-multipart
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
130 p = next(it, None)
5649
f8893e1cde0d assert_ is depricated. Replacing with assertTrue to reduce logs in travisci.
John Rouillard <rouilj@ieee.org>
parents: 5547
diff changeset
131 self.assertTrue(p is not None)
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
132 self.assertEqual(p.get_content_type(), 'multipart/alternative')
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
133
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
134 # sub-multipart text/plain
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
135 qit = iter(p.get_payload())
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
136 q = next(qit, None)
5649
f8893e1cde0d assert_ is depricated. Replacing with assertTrue to reduce logs in travisci.
John Rouillard <rouilj@ieee.org>
parents: 5547
diff changeset
137 self.assertTrue(q is not None)
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
138 self.assertEqual(q.get_content_type(), 'text/plain')
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
139 self.assertEqual(q.get_payload(), 'Hello, world!\r\n\r\nBlah blah\r\n')
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
140
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
141 # sub-multipart text/html
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
142 q = next(qit, None)
5649
f8893e1cde0d assert_ is depricated. Replacing with assertTrue to reduce logs in travisci.
John Rouillard <rouilj@ieee.org>
parents: 5547
diff changeset
143 self.assertTrue(q is not None)
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
144 self.assertEqual(q.get_content_type(), 'text/html')
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
145 self.assertEqual(q.get_payload(), '<b>Hello, world!</b>\r\n')
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
146
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
147 # sub-multipart end
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
148 q = next(qit, None)
5649
f8893e1cde0d assert_ is depricated. Replacing with assertTrue to reduce logs in travisci.
John Rouillard <rouilj@ieee.org>
parents: 5547
diff changeset
149 self.assertTrue(q is None)
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
150
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
151 # final text/plain
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
152 p = next(it, None)
5649
f8893e1cde0d assert_ is depricated. Replacing with assertTrue to reduce logs in travisci.
John Rouillard <rouilj@ieee.org>
parents: 5547
diff changeset
153 self.assertTrue(p is not None)
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
154 self.assertEqual(p.get_content_type(), 'text/plain')
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
155 self.assertEqual(p.get_payload(),
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
156 'Last bit\n')
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
157
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
158 # end
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
159 p = next(it, None)
5649
f8893e1cde0d assert_ is depricated. Replacing with assertTrue to reduce logs in travisci.
John Rouillard <rouilj@ieee.org>
parents: 5547
diff changeset
160 self.assertTrue(p is None)
110
19686b60e410 Multipart message class has the getPart method now. Added some tests for it.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
161
5306
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
162 def TestExtraction(self, spec, expected, convert_html_with=False):
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
163 if convert_html_with:
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
164 from roundup.dehtml import dehtml
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
165 html2text=dehtml(convert_html_with).html2text
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
166 else:
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
167 html2text=None
5305
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
168
5493
725266c03eab updated mailgw to no longer use mimetools based on jerrykan's patch
Christof Meerwald <cmeerw@cmeerw.org>
parents: 5418
diff changeset
169 self.assertEqual(gen_message(spec).extract_content(
5306
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
170 html2text=html2text), expected)
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
171
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
172 def testTextPlain(self):
5305
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
173 self.TestExtraction('text/plain', ('foo\n', [], False))
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
174
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
175 def testAttachedTextPlain(self):
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
176 self.TestExtraction("""
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
177 multipart/mixed
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
178 text/plain
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
179 text/plain""",
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
180 ('foo\n',
5305
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
181 [('foo.txt', 'text/plain', 'foo\n')], False))
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
182
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
183 def testMultipartMixed(self):
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
184 self.TestExtraction("""
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
185 multipart/mixed
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
186 text/plain
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
187 application/pdf""",
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
188 ('foo\n',
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
189 [('foo.pdf', 'application/pdf', b'foo\n')], False))
5305
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
190
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
191 def testMultipartMixedHtml(self):
5306
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
192 # test with html conversion enabled
5305
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
193 self.TestExtraction("""
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
194 multipart/mixed
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
195 text/html
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
196 application/pdf""",
5307
5b4931cfc182 Test entity code path in dehtml.
John Rouillard <rouilj@ieee.org>
parents: 5306
diff changeset
197 ('bar >\n',
5305
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
198 [('bar.html', 'text/html',
5307
5b4931cfc182 Test entity code path in dehtml.
John Rouillard <rouilj@ieee.org>
parents: 5306
diff changeset
199 '<html><body>bar &gt;</body></html>\n'),
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
200 ('foo.pdf', 'application/pdf', b'foo\n')], False),
5306
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
201 convert_html_with='dehtml')
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
202
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
203 # test with html conversion disabled
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
204 self.TestExtraction("""
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
205 multipart/mixed
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
206 text/html
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
207 application/pdf""",
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
208 (None,
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
209 [('bar.html', 'text/html',
5307
5b4931cfc182 Test entity code path in dehtml.
John Rouillard <rouilj@ieee.org>
parents: 5306
diff changeset
210 '<html><body>bar &gt;</body></html>\n'),
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
211 ('foo.pdf', 'application/pdf', b'foo\n')], False),
5306
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
212 convert_html_with=False)
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
213
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
214 def testMultipartAlternative(self):
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
215 self.TestExtraction("""
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
216 multipart/alternative
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
217 text/plain
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
218 application/pdf
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
219 """, ('foo\n', [('foo.pdf', 'application/pdf', b'foo\n')], False))
5305
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
220
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
221 def testMultipartAlternativeHtml(self):
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
222 self.TestExtraction("""
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
223 multipart/alternative
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
224 text/html
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
225 application/pdf""",
5307
5b4931cfc182 Test entity code path in dehtml.
John Rouillard <rouilj@ieee.org>
parents: 5306
diff changeset
226 ('bar >\n',
5305
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
227 [('bar.html', 'text/html',
5307
5b4931cfc182 Test entity code path in dehtml.
John Rouillard <rouilj@ieee.org>
parents: 5306
diff changeset
228 '<html><body>bar &gt;</body></html>\n'),
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
229 ('foo.pdf', 'application/pdf', b'foo\n')], False),
5306
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
230 convert_html_with='dehtml')
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
231
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
232 self.TestExtraction("""
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
233 multipart/alternative
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
234 text/html
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
235 application/pdf""",
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
236 (None,
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
237 [('bar.html', 'text/html',
5307
5b4931cfc182 Test entity code path in dehtml.
John Rouillard <rouilj@ieee.org>
parents: 5306
diff changeset
238 '<html><body>bar &gt;</body></html>\n'),
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
239 ('foo.pdf', 'application/pdf', b'foo\n')], False),
5306
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
240 convert_html_with=False)
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
241
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
242 def testMultipartAlternativeHtmlText(self):
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
243 # text should take priority over html when html is first
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
244 self.TestExtraction("""
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
245 multipart/alternative
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
246 text/html
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
247 text/plain
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
248 application/pdf""",
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
249 ('foo\n',
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
250 [('bar.html', 'text/html',
5307
5b4931cfc182 Test entity code path in dehtml.
John Rouillard <rouilj@ieee.org>
parents: 5306
diff changeset
251 '<html><body>bar &gt;</body></html>\n'),
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
252 ('foo.pdf', 'application/pdf', b'foo\n')], False),
5306
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
253 convert_html_with='dehtml')
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
254
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
255 # text should take priority over html when text is first
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
256 self.TestExtraction("""
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
257 multipart/alternative
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
258 text/plain
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
259 text/html
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
260 application/pdf""",
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
261 ('foo\n',
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
262 [('bar.html', 'text/html',
5307
5b4931cfc182 Test entity code path in dehtml.
John Rouillard <rouilj@ieee.org>
parents: 5306
diff changeset
263 '<html><body>bar &gt;</body></html>\n'),
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
264 ('foo.pdf', 'application/pdf', b'foo\n')], False),
5306
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
265 convert_html_with='dehtml')
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
266
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
267 # text should take priority over html when text is second and
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
268 # html is disabled
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
269 self.TestExtraction("""
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
270 multipart/alternative
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
271 text/html
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
272 text/plain
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
273 application/pdf""",
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
274 ('foo\n',
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
275 [('bar.html', 'text/html',
5307
5b4931cfc182 Test entity code path in dehtml.
John Rouillard <rouilj@ieee.org>
parents: 5306
diff changeset
276 '<html><body>bar &gt;</body></html>\n'),
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
277 ('foo.pdf', 'application/pdf', b'foo\n')], False),
5306
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
278 convert_html_with=False)
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
279
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
280 # text should take priority over html when text is first and
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
281 # html is disabled
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
282 self.TestExtraction("""
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
283 multipart/alternative
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
284 text/plain
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
285 text/html
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
286 application/pdf""",
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
287 ('foo\n',
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
288 [('bar.html', 'text/html',
5307
5b4931cfc182 Test entity code path in dehtml.
John Rouillard <rouilj@ieee.org>
parents: 5306
diff changeset
289 '<html><body>bar &gt;</body></html>\n'),
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
290 ('foo.pdf', 'application/pdf', b'foo\n')], False),
5306
91354bf0b683 Codecov showed text/html followed by text/plain not tested. Fixed bug
John Rouillard <rouilj@ieee.org>
parents: 5305
diff changeset
291 convert_html_with=False)
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
292
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
293 def testDeepMultipartAlternative(self):
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
294 self.TestExtraction("""
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
295 multipart/mixed
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
296 multipart/alternative
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
297 text/plain
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
298 application/pdf
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
299 """, ('foo\n', [('foo.pdf', 'application/pdf', b'foo\n')], False))
3915
6b3919328381 support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents: 1975
diff changeset
300
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
301 def testSignedText(self):
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
302 self.TestExtraction("""
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
303 multipart/signed
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
304 text/plain
5305
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
305 application/pgp-signature""", ('foo\n', [], False))
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
306
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
307 def testSignedAttachments(self):
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
308 self.TestExtraction("""
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
309 multipart/signed
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
310 multipart/mixed
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
311 text/plain
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
312 application/pdf
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
313 application/pgp-signature""",
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
314 ('foo\n',
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
315 [('foo.pdf', 'application/pdf', b'foo\n')], False))
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
316
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
317 def testAttachedSignature(self):
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
318 self.TestExtraction("""
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
319 multipart/mixed
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
320 text/plain
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
321 application/pgp-signature""",
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
322 ('foo\n',
5547
081be318661b Do not transcode binary email attachments (issue2551004).
Joseph Myers <jsm@polyomino.org.uk>
parents: 5493
diff changeset
323 [('foo.gpg', 'application/pgp-signature', b'foo\n')], False))
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
324
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
325 def testMessageRfc822(self):
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
326 self.TestExtraction("""
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
327 multipart/mixed
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
328 message/rfc822""",
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
329 (None,
5305
e20f472fde7d issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents: 5037
diff changeset
330 [('foo.eml', 'message/rfc822', 'Subject: foo\n\nfoo\n')], False))
1975
30a444b7b212 *** empty log message ***
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents: 1873
diff changeset
331
127
0791d13baea7 Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents: 110
diff changeset
332 # vim: set filetype=python ts=4 sw=4 et si

Roundup Issue Tracker: http://roundup-tracker.org/