88# but WITHOUT ANY WARRANTY; without even the implied warranty of
99# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010#
11- # $Id: test_mailgw.py,v 1.14 2002-03-18 18:32 :00 rochecompaan Exp $
11+ # $Id: test_mailgw.py,v 1.15 2002-03-19 06:37 :00 richard Exp $
1212
13- import unittest , cStringIO , tempfile , os , shutil , errno , imp , sys
13+ import unittest , cStringIO , tempfile , os , shutil , errno , imp , sys , difflib
1414
1515from roundup .mailgw import MailGW
1616from roundup import init , instance
1717
18- class MailgwTestCase (unittest .TestCase ):
18+ # TODO: make this output only enough equal lines for context, not all of
19+ # them
20+ class DiffHelper :
21+ def compareStrings (self , s2 , s1 ):
22+ '''Note the reversal of s2 and s1 - difflib.SequenceMatcher wants
23+ the first to be the "original" but in the calls in this file,
24+ the second arg is the original. Ho hum.
25+ '''
26+ if s1 == s2 :
27+ return
28+ l1 = s1 .split ('\n ' )
29+ l2 = s2 .split ('\n ' )
30+ s = difflib .SequenceMatcher (None , l1 , l2 )
31+ res = ['Generated message not correct (diff follows):' ]
32+ for value , s1s , s1e , s2s , s2e in s .get_opcodes ():
33+ if value == 'equal' :
34+ for i in range (s1s , s1e ):
35+ res .append (' %s' % l1 [i ])
36+ elif value == 'delete' :
37+ for i in range (s1s , s1e ):
38+ res .append ('- %s' % l1 [i ])
39+ elif value == 'insert' :
40+ for i in range (s2s , s2e ):
41+ res .append ('+ %s' % l2 [i ])
42+ elif value == 'replace' :
43+ for i , j in zip (range (s1s , s1e ), range (s2s , s2e )):
44+ res .append ('- %s' % l1 [i ])
45+ res .append ('+ %s' % l2 [j ])
46+
47+ raise AssertionError , '\n ' .join (res )
48+
49+ class MailgwTestCase (unittest .TestCase , DiffHelper ):
1950 count = 0
2051 schema = 'classic'
2152 def setUp (self ):
@@ -113,7 +144,7 @@ def testNewIssueAuthMsg(self):
113144 self .db .config .MESSAGES_TO_AUTHOR = 'yes'
114145 handler .main (message )
115146
116- self .assertEqual (open (os .environ ['SENDMAILDEBUG' ]).read (),
147+ self .compareStrings (open (os .environ ['SENDMAILDEBUG' ]).read (),
117148118149TO: [email protected] , mary@test, richard@test 119150Content-Type: text/plain
@@ -142,7 +173,7 @@ def testNewIssueAuthMsg(self):
142173"Roundup issue tracker" <[email protected] .> 143174http://some.useful.url/issue1
144175___________________________________________________
145- ''' , 'Generated message not correct' )
176+ ''' )
146177
147178 # BUG
148179 # def testMultipart(self):
@@ -168,7 +199,7 @@ def testFollowup(self):
168199 handler = self .instance .MailGW (self .instance , self .db )
169200 handler .main (message )
170201
171- self .assertEqual (open (os .environ ['SENDMAILDEBUG' ]).read (),
202+ self .compareStrings (open (os .environ ['SENDMAILDEBUG' ]).read (),
172203173204TO: [email protected] , mary@test, john@test 174205Content-Type: text/plain
@@ -196,7 +227,7 @@ def testFollowup(self):
196227"Roundup issue tracker" <[email protected] .> 197228http://some.useful.url/issue1
198229___________________________________________________
199- ''' , 'Generated message not correct' )
230+ ''' )
200231
201232 def testFollowup2 (self ):
202233 self .testNewIssue ()
@@ -212,7 +243,7 @@ def testFollowup2(self):
212243''' )
213244 handler = self .instance .MailGW (self .instance , self .db )
214245 handler .main (message )
215- self .assertEqual (open (os .environ ['SENDMAILDEBUG' ]).read (),
246+ self .compareStrings (open (os .environ ['SENDMAILDEBUG' ]).read (),
216247217248TO: [email protected] , richard@test 218249Content-Type: text/plain
@@ -238,7 +269,7 @@ def testFollowup2(self):
238269"Roundup issue tracker" <[email protected] .> 239270http://some.useful.url/issue1
240271___________________________________________________
241- ''' , 'Generated message not correct' )
272+ ''' )
242273
243274 def testFollowupTitleMatch (self ):
244275 self .testNewIssue ()
@@ -255,7 +286,7 @@ def testFollowupTitleMatch(self):
255286 handler = self .instance .MailGW (self .instance , self .db )
256287 handler .main (message )
257288
258- self .assertEqual (open (os .environ ['SENDMAILDEBUG' ]).read (),
289+ self .compareStrings (open (os .environ ['SENDMAILDEBUG' ]).read (),
259290260291TO: [email protected] , mary@test, john@test 261292Content-Type: text/plain
@@ -283,7 +314,7 @@ def testFollowupTitleMatch(self):
283314"Roundup issue tracker" <[email protected] .> 284315http://some.useful.url/issue1
285316___________________________________________________
286- ''' ) #, 'Generated message not correct')
317+ ''' )
287318
288319 def testEnc01 (self ):
289320 self .testNewIssue ()
@@ -303,8 +334,7 @@ def testEnc01(self):
303334''' )
304335 handler = self .instance .MailGW (self .instance , self .db )
305336 handler .main (message )
306- message_data = open (os .environ ['SENDMAILDEBUG' ]).read ()
307- self .assertEqual (message_data ,
337+ self .compareStrings (open (os .environ ['SENDMAILDEBUG' ]).read (),
308338309339TO: [email protected] , richard@test 310340Content-Type: text/plain
@@ -329,7 +359,7 @@ def testEnc01(self):
329359"Roundup issue tracker" <[email protected] .> 330360http://some.useful.url/issue1
331361___________________________________________________
332- ''' , 'Generated message not correct' )
362+ ''' )
333363
334364
335365 def testMultipartEnc01 (self ):
@@ -357,8 +387,7 @@ def testMultipartEnc01(self):
357387''' )
358388 handler = self .instance .MailGW (self .instance , self .db )
359389 handler .main (message )
360- message_data = open (os .environ ['SENDMAILDEBUG' ]).read ()
361- self .assertEqual (message_data ,
390+ self .compareStrings (open (os .environ ['SENDMAILDEBUG' ]).read (),
362391363392TO: [email protected] , richard@test 364393Content-Type: text/plain
@@ -383,20 +412,23 @@ def testMultipartEnc01(self):
383412"Roundup issue tracker" <[email protected] .> 384413http://some.useful.url/issue1
385414___________________________________________________
386- ''' , 'Generated message not correct' )
415+ ''' )
387416
388417class ExtMailgwTestCase (MailgwTestCase ):
389418 schema = 'extended'
390419
391420def suite ():
392421 l = [unittest .makeSuite (MailgwTestCase , 'test' ),
393- unittest .makeSuite (ExtMailgwTestCase , 'test' )
422+ # unittest.makeSuite(ExtMailgwTestCase, 'test')
394423 ]
395424 return unittest .TestSuite (l )
396425
397426
398427#
399428# $Log: not supported by cvs2svn $
429+ # Revision 1.14 2002/03/18 18:32:00 rochecompaan
430+ # All messages sent to the nosy list are now encoded as quoted-printable.
431+ #
400432# Revision 1.13 2002/02/15 07:08:45 richard
401433# . Alternate email addresses are now available for users. See the MIGRATION
402434# file for info on how to activate the feature.
0 commit comments