comparison test/test_mailgw.py @ 2708:223f4fb26a75 maint-0.7

testRegistrationConfirmation: remove CR at the end of the first line... ... of split "Subject:" header. i don't think it was intentional (there ain't no such thing on split "Content-Type:" line), and it breaks header parsing on windows (CR is treated as newline, i.e. we get two newlines in a row). trim trailing spaces; fix vim modeline
author Alexander Smishlajev <a1s@users.sourceforge.net>
date Wed, 29 Sep 2004 09:16:09 +0000
parents 77461135596d
children
comparison
equal deleted inserted replaced
2707:7f24a0222d36 2708:223f4fb26a75
6 # 6 #
7 # This module is distributed in the hope that it will be useful, 7 # This module is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 # 10 #
11 # $Id: test_mailgw.py,v 1.69 2004-04-20 21:55:45 richard Exp $ 11 # $Id: test_mailgw.py,v 1.69.2.1 2004-09-29 09:16:09 a1s Exp $
12 12
13 # TODO: test bcc 13 # TODO: test bcc
14 14
15 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 15 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822
16 16
27 27
28 class Message(rfc822.Message): 28 class Message(rfc822.Message):
29 """String-based Message class with equivalence test.""" 29 """String-based Message class with equivalence test."""
30 def __init__(self, s): 30 def __init__(self, s):
31 rfc822.Message.__init__(self, StringIO(s.strip())) 31 rfc822.Message.__init__(self, StringIO(s.strip()))
32 32
33 def __eq__(self, other): 33 def __eq__(self, other):
34 return (self.dict == other.dict and 34 return (self.dict == other.dict and
35 self.fp.read() == other.fp.read()) 35 self.fp.read() == other.fp.read())
36 36
37 class DiffHelper: 37 class DiffHelper:
38 def compareMessages(self, new, old): 38 def compareMessages(self, new, old):
39 """Compare messages for semantic equivalence.""" 39 """Compare messages for semantic equivalence."""
40 new, old = Message(new), Message(old) 40 new, old = Message(new), Message(old)
58 res.extend(body_diff) 58 res.extend(body_diff)
59 59
60 if res: 60 if res:
61 res.insert(0, 'Generated message not correct (diff follows):') 61 res.insert(0, 'Generated message not correct (diff follows):')
62 raise AssertionError, '\n'.join(res) 62 raise AssertionError, '\n'.join(res)
63 63
64 def compareStrings(self, s2, s1): 64 def compareStrings(self, s2, s1):
65 '''Note the reversal of s2 and s1 - difflib.SequenceMatcher wants 65 '''Note the reversal of s2 and s1 - difflib.SequenceMatcher wants
66 the first to be the "original" but in the calls in this file, 66 the first to be the "original" but in the calls in this file,
67 the second arg is the original. Ho hum. 67 the second arg is the original. Ho hum.
68 ''' 68 '''
133 handler.trapExceptions = 0 133 handler.trapExceptions = 0
134 ret = handler.main(StringIO(message)) 134 ret = handler.main(StringIO(message))
135 # handler can close the db on us and open a new one 135 # handler can close the db on us and open a new one
136 self.db = handler.db 136 self.db = handler.db
137 return ret 137 return ret
138 138
139 def _get_mail(self): 139 def _get_mail(self):
140 f = open(SENDMAILDEBUG) 140 f = open(SENDMAILDEBUG)
141 try: 141 try:
142 return f.read() 142 return f.read()
143 finally: 143 finally:
202 Message-Id: <dummy_test_message_id> 202 Message-Id: <dummy_test_message_id>
203 Subject: [issue] Testing... 203 Subject: [issue] Testing...
204 204
205 This is a test submission of a new issue. 205 This is a test submission of a new issue.
206 ''') 206 ''')
207 userlist = self.db.user.list() 207 userlist = self.db.user.list()
208 assert not os.path.exists(SENDMAILDEBUG) 208 assert not os.path.exists(SENDMAILDEBUG)
209 self.assertEqual(userlist, self.db.user.list(), 209 self.assertEqual(userlist, self.db.user.list(),
210 "user created when it shouldn't have been") 210 "user created when it shouldn't have been")
211 211
212 def testNewIssueNoClass(self): 212 def testNewIssueNoClass(self):
269 # BUG 269 # BUG
270 # def testMultipart(self): 270 # def testMultipart(self):
271 # '''With more than one part''' 271 # '''With more than one part'''
272 # see MultipartEnc tests: but if there is more than one part 272 # see MultipartEnc tests: but if there is more than one part
273 # we return a multipart/mixed and the boundary contains 273 # we return a multipart/mixed and the boundary contains
274 # the ip address of the test machine. 274 # the ip address of the test machine.
275 275
276 # BUG should test some binary attamchent too. 276 # BUG should test some binary attamchent too.
277 277
278 def testSimpleFollowup(self): 278 def testSimpleFollowup(self):
279 self.doNewIssue() 279 self.doNewIssue()
806 From: mary <mary@test> 806 From: mary <mary@test>
807 To: issue_tracker@your.tracker.email.domain.example 807 To: issue_tracker@your.tracker.email.domain.example
808 Message-Id: <followup_dummy_id> 808 Message-Id: <followup_dummy_id>
809 In-Reply-To: <dummy_test_message_id> 809 In-Reply-To: <dummy_test_message_id>
810 Subject: [issue1] Testing... 810 Subject: [issue1] Testing...
811 Content-Type: multipart/mixed; boundary="bCsyhTFzCvuiizWE" 811 Content-Type: multipart/mixed; boundary="bCsyhTFzCvuiizWE"
812 Content-Disposition: inline 812 Content-Disposition: inline
813 813
814 814
815 --bCsyhTFzCvuiizWE 815 --bCsyhTFzCvuiizWE
816 Content-Type: text/plain; charset=us-ascii 816 Content-Type: text/plain; charset=us-ascii
817 Content-Disposition: inline 817 Content-Disposition: inline
818 818
819 test attachment binary 819 test attachment binary
820 820
821 --bCsyhTFzCvuiizWE 821 --bCsyhTFzCvuiizWE
822 Content-Type: application/octet-stream 822 Content-Type: application/octet-stream
823 Content-Disposition: attachment; filename="main.dvi" 823 Content-Disposition: attachment; filename="main.dvi"
824 824
825 xxxxxx 825 xxxxxx
826 826
827 --bCsyhTFzCvuiizWE-- 827 --bCsyhTFzCvuiizWE--
828 ''') 828 ''')
829 messages = self.db.issue.get('1', 'messages') 829 messages = self.db.issue.get('1', 'messages')
830 messages.sort() 830 messages.sort()
965 To: issue_tracker@your.tracker.email.domain.example 965 To: issue_tracker@your.tracker.email.domain.example
966 Message-Id: <followup_dummy_id> 966 Message-Id: <followup_dummy_id>
967 In-Reply-To: <dummy_test_message_id> 967 In-Reply-To: <dummy_test_message_id>
968 Subject: [keyword1] Testing... [name=Bar] 968 Subject: [keyword1] Testing... [name=Bar]
969 969
970 ''') 970 ''')
971 self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar') 971 self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar')
972 972
973 def testResentFrom(self): 973 def testResentFrom(self):
974 nodeid = self._handle_mail('''Content-Type: text/plain; 974 nodeid = self._handle_mail('''Content-Type: text/plain;
975 charset="iso-8859-1" 975 charset="iso-8859-1"
1024 1024
1025 if __name__ == '__main__': 1025 if __name__ == '__main__':
1026 runner = unittest.TextTestRunner() 1026 runner = unittest.TextTestRunner()
1027 unittest.main(testRunner=runner) 1027 unittest.main(testRunner=runner)
1028 1028
1029 # vim: set filetype=python ts=4 sw=4 et si 1029 # vim: set filetype=python sts=4 sw=4 et si :

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