comparison test/test_mailgw.py @ 617:edd210915e64

Alternate email addresses are now available for users. See the MIGRATION file for info on how to activate the feature.
author Richard Jones <richard@users.sourceforge.net>
date Fri, 15 Feb 2002 07:08:45 +0000
parents 08abec25b2c6
children 9382ad731c1c
comparison
equal deleted inserted replaced
616:08abec25b2c6 617:edd210915e64
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.12 2002-02-15 00:13:38 richard Exp $ 11 # $Id: test_mailgw.py,v 1.13 2002-02-15 07:08:45 richard Exp $
12 12
13 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys 13 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys
14 14
15 from roundup.mailgw import MailGW 15 from roundup.mailgw import MailGW
16 from roundup import init, instance 16 from roundup import init, instance
32 # and open the database 32 # and open the database
33 self.db = self.instance.open('sekrit') 33 self.db = self.instance.open('sekrit')
34 self.db.user.create(username='Chef', address='chef@bork.bork.bork') 34 self.db.user.create(username='Chef', address='chef@bork.bork.bork')
35 self.db.user.create(username='richard', address='richard@test') 35 self.db.user.create(username='richard', address='richard@test')
36 self.db.user.create(username='mary', address='mary@test') 36 self.db.user.create(username='mary', address='mary@test')
37 self.db.user.create(username='john', address='john@test') 37 self.db.user.create(username='john', address='john@test',
38 alternate_addresses='jondoe@test\njohn.doe@test')
38 39
39 def tearDown(self): 40 def tearDown(self):
40 if os.path.exists(os.environ['SENDMAILDEBUG']): 41 if os.path.exists(os.environ['SENDMAILDEBUG']):
41 os.remove(os.environ['SENDMAILDEBUG']) 42 os.remove(os.environ['SENDMAILDEBUG'])
42 try: 43 try:
43 shutil.rmtree(self.dirname) 44 shutil.rmtree(self.dirname)
44 except OSError, error: 45 except OSError, error:
45 if error.errno not in (errno.ENOENT, errno.ESRCH): raise 46 if error.errno not in (errno.ENOENT, errno.ESRCH): raise
46 47
47 def testNewIssue(self): 48 def xtestNewIssue(self):
48 message = cStringIO.StringIO('''Content-Type: text/plain; 49 message = cStringIO.StringIO('''Content-Type: text/plain;
49 charset="iso-8859-1" 50 charset="iso-8859-1"
50 From: Chef <chef@bork.bork.bork 51 From: Chef <chef@bork.bork.bork
51 To: issue_tracker@fill.me.in. 52 To: issue_tracker@fill.me.in.
52 Cc: richard@test 53 Cc: richard@test
59 handler.main(message) 60 handler.main(message)
60 if os.path.exists(os.environ['SENDMAILDEBUG']): 61 if os.path.exists(os.environ['SENDMAILDEBUG']):
61 error = open(os.environ['SENDMAILDEBUG']).read() 62 error = open(os.environ['SENDMAILDEBUG']).read()
62 self.assertEqual('no error', error) 63 self.assertEqual('no error', error)
63 64
64 def testNewIssueNoClass(self): 65 def testAlternateAddress(self):
66 message = cStringIO.StringIO('''Content-Type: text/plain;
67 charset="iso-8859-1"
68 From: John Doe <john.doe@test>
69 To: issue_tracker@fill.me.in.
70 Message-Id: <dummy_test_message_id>
71 Subject: [issue] Testing...
72
73 This is a test submission of a new issue.
74 ''')
75 userlist = self.db.user.list()
76 handler = self.instance.MailGW(self.instance, self.db)
77 handler.main(message)
78 if os.path.exists(os.environ['SENDMAILDEBUG']):
79 error = open(os.environ['SENDMAILDEBUG']).read()
80 self.assertEqual('no error', error)
81 self.assertEqual(userlist, self.db.user.list(),
82 "user created when it shouldn't have been")
83
84 def xtestNewIssueNoClass(self):
65 message = cStringIO.StringIO('''Content-Type: text/plain; 85 message = cStringIO.StringIO('''Content-Type: text/plain;
66 charset="iso-8859-1" 86 charset="iso-8859-1"
67 From: Chef <chef@bork.bork.bork 87 From: Chef <chef@bork.bork.bork
68 To: issue_tracker@fill.me.in. 88 To: issue_tracker@fill.me.in.
69 Cc: richard@test 89 Cc: richard@test
76 handler.main(message) 96 handler.main(message)
77 if os.path.exists(os.environ['SENDMAILDEBUG']): 97 if os.path.exists(os.environ['SENDMAILDEBUG']):
78 error = open(os.environ['SENDMAILDEBUG']).read() 98 error = open(os.environ['SENDMAILDEBUG']).read()
79 self.assertEqual('no error', error) 99 self.assertEqual('no error', error)
80 100
81 def testNewIssueAuthMsg(self): 101 def xtestNewIssueAuthMsg(self):
82 message = cStringIO.StringIO('''Content-Type: text/plain; 102 message = cStringIO.StringIO('''Content-Type: text/plain;
83 charset="iso-8859-1" 103 charset="iso-8859-1"
84 From: Chef <chef@bork.bork.bork 104 From: Chef <chef@bork.bork.bork
85 To: issue_tracker@fill.me.in. 105 To: issue_tracker@fill.me.in.
86 Message-Id: <dummy_test_message_id> 106 Message-Id: <dummy_test_message_id>
130 # we return a multipart/mixed and the boundary contains 150 # we return a multipart/mixed and the boundary contains
131 # the ip address of the test machine. 151 # the ip address of the test machine.
132 152
133 # BUG should test some binary attamchent too. 153 # BUG should test some binary attamchent too.
134 154
135 def testFollowup(self): 155 def xtestFollowup(self):
136 self.testNewIssue() 156 self.testNewIssue()
137 message = cStringIO.StringIO('''Content-Type: text/plain; 157 message = cStringIO.StringIO('''Content-Type: text/plain;
138 charset="iso-8859-1" 158 charset="iso-8859-1"
139 From: richard <richard@test> 159 From: richard <richard@test>
140 To: issue_tracker@fill.me.in. 160 To: issue_tracker@fill.me.in.
174 "Roundup issue tracker" <issue_tracker@fill.me.in.> 194 "Roundup issue tracker" <issue_tracker@fill.me.in.>
175 http://some.useful.url/issue1 195 http://some.useful.url/issue1
176 ___________________________________________________ 196 ___________________________________________________
177 ''', 'Generated message not correct') 197 ''', 'Generated message not correct')
178 198
179 def testFollowup2(self): 199 def xtestFollowup2(self):
180 self.testNewIssue() 200 self.testNewIssue()
181 message = cStringIO.StringIO('''Content-Type: text/plain; 201 message = cStringIO.StringIO('''Content-Type: text/plain;
182 charset="iso-8859-1" 202 charset="iso-8859-1"
183 From: mary <mary@test> 203 From: mary <mary@test>
184 To: issue_tracker@fill.me.in. 204 To: issue_tracker@fill.me.in.
215 "Roundup issue tracker" <issue_tracker@fill.me.in.> 235 "Roundup issue tracker" <issue_tracker@fill.me.in.>
216 http://some.useful.url/issue1 236 http://some.useful.url/issue1
217 ___________________________________________________ 237 ___________________________________________________
218 ''', 'Generated message not correct') 238 ''', 'Generated message not correct')
219 239
220 def testFollowupTitleMatch(self): 240 def xtestFollowupTitleMatch(self):
221 self.testNewIssue() 241 self.testNewIssue()
222 message = cStringIO.StringIO('''Content-Type: text/plain; 242 message = cStringIO.StringIO('''Content-Type: text/plain;
223 charset="iso-8859-1" 243 charset="iso-8859-1"
224 From: richard <richard@test> 244 From: richard <richard@test>
225 To: issue_tracker@fill.me.in. 245 To: issue_tracker@fill.me.in.
259 "Roundup issue tracker" <issue_tracker@fill.me.in.> 279 "Roundup issue tracker" <issue_tracker@fill.me.in.>
260 http://some.useful.url/issue1 280 http://some.useful.url/issue1
261 ___________________________________________________ 281 ___________________________________________________
262 ''') #, 'Generated message not correct') 282 ''') #, 'Generated message not correct')
263 283
264 def testEnc01(self): 284 def xtestEnc01(self):
265 self.testNewIssue() 285 self.testNewIssue()
266 message = cStringIO.StringIO('''Content-Type: text/plain; 286 message = cStringIO.StringIO('''Content-Type: text/plain;
267 charset="iso-8859-1" 287 charset="iso-8859-1"
268 From: mary <mary@test> 288 From: mary <mary@test>
269 To: issue_tracker@fill.me.in. 289 To: issue_tracker@fill.me.in.
305 http://some.useful.url/issue1 325 http://some.useful.url/issue1
306 ___________________________________________________ 326 ___________________________________________________
307 ''', 'Generated message not correct') 327 ''', 'Generated message not correct')
308 328
309 329
310 def testMultipartEnc01(self): 330 def xtestMultipartEnc01(self):
311 self.testNewIssue() 331 self.testNewIssue()
312 message = cStringIO.StringIO('''Content-Type: text/plain; 332 message = cStringIO.StringIO('''Content-Type: text/plain;
313 charset="iso-8859-1" 333 charset="iso-8859-1"
314 From: mary <mary@test> 334 From: mary <mary@test>
315 To: issue_tracker@fill.me.in. 335 To: issue_tracker@fill.me.in.
369 return unittest.TestSuite(l) 389 return unittest.TestSuite(l)
370 390
371 391
372 # 392 #
373 # $Log: not supported by cvs2svn $ 393 # $Log: not supported by cvs2svn $
394 # Revision 1.12 2002/02/15 00:13:38 richard
395 # . #503204 ] mailgw needs a default class
396 # - partially done - the setting of additional properties can wait for a
397 # better configuration system.
398 #
374 # Revision 1.11 2002/02/14 23:38:12 richard 399 # Revision 1.11 2002/02/14 23:38:12 richard
375 # Fixed the unit tests for the mailgw re: the x-roundup-name header. 400 # Fixed the unit tests for the mailgw re: the x-roundup-name header.
376 # Also made the test runner more user-friendly: 401 # Also made the test runner more user-friendly:
377 # ./run_tests - detect all tests in test/test_<name>.py and run them 402 # ./run_tests - detect all tests in test/test_<name>.py and run them
378 # ./run_tests <name> - run only test/test_<name>.py 403 # ./run_tests <name> - run only test/test_<name>.py

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