Code

followup lines directly after a quoted section were being eaten.
[roundup.git] / test / test_mailsplit.py
1 #
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3 # This module is free software, and you may redistribute it and/or modify
4 # under the same terms as Python, so long as this copyright message and
5 # disclaimer are retained in their original form.
6 #
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10 # POSSIBILITY OF SUCH DAMAGE.
11 #
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17
18 # $Id: test_mailsplit.py,v 1.9 2002-01-10 06:19:20 richard Exp $
20 import unittest, cStringIO
22 from roundup.mailgw import parseContent
24 class MailsplitTestCase(unittest.TestCase):
25     def testPreComment(self):
26         s = '''
27 blah blah blah blah... blah blah? blah blah blah blah blah. blah blah blah
28 blah blah blah blah blah blah blah blah blah blah blah!
30 issue_tracker@foo.com wrote:
31 > blah blah blah blahblah blahblah blahblah blah blah blah blah blah blah
32 > blah blah blah blah blah blah blah blah blah?  blah blah blah blah blah
33 > blah blah blah blah blah blah blah...  blah blah blah blah.  blah blah
34 > blah blah blah blah?  blah blah blah blah blah blah!  blah blah!
35 >
36 > -------
37 > nosy: userfoo, userken
38 > _________________________________________________
39 > Roundup issue tracker
40 > issue_tracker@foo.com
41 > http://foo.com/cgi-bin/roundup.cgi/issue_tracker/
43 --
44 blah blah blah signature
45 userfoo@foo.com
46 '''
47         summary, content = parseContent(s)
48         self.assertEqual(summary, 'blah blah blah blah... blah blah? blah blah blah blah blah. blah blah blah')
49         self.assertEqual(content, 'blah blah blah blah... blah blah? blah blah blah blah blah. blah blah blah\nblah blah blah blah blah blah blah blah blah blah blah!')
51     def testPostComment(self):
52         s = '''
53 issue_tracker@foo.com wrote:
54 > blah blah blah blahblah blahblah blahblah blah blah blah blah blah
55 > blah
56 > blah blah blah blah blah blah blah blah blah?  blah blah blah blah
57 > blah
58 > blah blah blah blah blah blah blah...  blah blah blah blah.  blah
59 > blah
60 > blah blah blah blah?  blah blah blah blah blah blah!  blah blah!
61 >
62 > -------
63 > nosy: userfoo, userken
64 > _________________________________________________
65 > Roundup issue tracker
66 > issue_tracker@foo.com
67 > http://foo.com/cgi-bin/roundup.cgi/issue_tracker/
69 blah blah blah blah... blah blah? blah blah blah blah blah. blah blah blah
70 blah blah blah blah blah blah blah blah blah blah blah!
72 --
73 blah blah blah signature
74 userfoo@foo.com
75 '''
76         summary, content = parseContent(s)
77         self.assertEqual(summary, 'blah blah blah blah... blah blah? blah blah blah blah blah. blah blah blah')
78         self.assertEqual(content, 'blah blah blah blah... blah blah? blah blah blah blah blah. blah blah blah\nblah blah blah blah blah blah blah blah blah blah blah!')
80     def testSimple(self):
81         s = '''testing'''
82         summary, content = parseContent(s)
83         self.assertEqual(summary, 'testing')
84         self.assertEqual(content, 'testing')
86     def testParagraphs(self):
87         s = '''testing\n\ntesting\n\ntesting'''
88         summary, content = parseContent(s)
89         self.assertEqual(summary, 'testing')
90         self.assertEqual(content, 'testing\n\ntesting\n\ntesting')
92     def testSimpleFollowup(self):
93         s = '''>hello\ntesting'''
94         summary, content = parseContent(s)
95         self.assertEqual(summary, 'testing')
96         self.assertEqual(content, 'testing')
98     def testSimpleFollowupParas(self):
99         s = '''>hello\ntesting\n\ntesting\n\ntesting'''
100         summary, content = parseContent(s)
101         self.assertEqual(summary, 'testing')
102         self.assertEqual(content, 'testing\n\ntesting\n\ntesting')
104     def testEmpty(self):
105         s = ''
106         summary, content = parseContent(s)
107         self.assertEqual(summary, '')
108         self.assertEqual(content, '')
110     def testIndentationSummary(self):
111         s = '    Four space indent.\n\n    Four space indent.\nNo indent.'
112         summary, content = parseContent(s)
113         self.assertEqual(summary, '    Four space indent.')
115     def testIndentationContent(self):
116         s = '    Four space indent.\n\n    Four space indent.\nNo indent.'
117         summary, content = parseContent(s)
118         self.assertEqual(content, s)
120 def suite():
121    return unittest.makeSuite(MailsplitTestCase, 'test')
125 # $Log: not supported by cvs2svn $
126 # Revision 1.8  2001/10/28 23:22:28  richard
127 # fixed bug #474749 ] Indentations lost
129 # Revision 1.7  2001/10/23 00:57:32  richard
130 # Removed debug print from mailsplit test.
132 # Revision 1.6  2001/10/21 03:35:13  richard
133 # bug #473125: Paragraph in e-mails
135 # Revision 1.5  2001/08/07 00:24:43  richard
136 # stupid typo
138 # Revision 1.4  2001/08/07 00:15:51  richard
139 # Added the copyright/license notice to (nearly) all files at request of
140 # Bizar Software.
142 # Revision 1.3  2001/08/05 07:06:25  richard
143 # removed some print statements
145 # Revision 1.2  2001/08/03 07:23:09  richard
146 # er, removed the innocent from the the code :)
148 # Revision 1.1  2001/08/03 07:18:22  richard
149 # Implemented correct mail splitting (was taking a shortcut). Added unit
150 # tests. Also snips signatures now too.
154 # vim: set filetype=python ts=4 sw=4 et si