comparison test/test_mailgw.py @ 616:08abec25b2c6

[SF#503204] mailgw needs a default class - partially done - the setting of additional properties can wait for a better configuration system.
author Richard Jones <richard@users.sourceforge.net>
date Fri, 15 Feb 2002 00:13:38 +0000
parents d77b82588bf0
children edd210915e64
comparison
equal deleted inserted replaced
615:7c2c4840db6a 616:08abec25b2c6
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.11 2002-02-14 23:38:12 richard Exp $ 11 # $Id: test_mailgw.py,v 1.12 2002-02-15 00:13:38 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
59 handler.main(message) 59 handler.main(message)
60 if os.path.exists(os.environ['SENDMAILDEBUG']): 60 if os.path.exists(os.environ['SENDMAILDEBUG']):
61 error = open(os.environ['SENDMAILDEBUG']).read() 61 error = open(os.environ['SENDMAILDEBUG']).read()
62 self.assertEqual('no error', error) 62 self.assertEqual('no error', error)
63 63
64 def testNewIssueNoClass(self):
65 message = cStringIO.StringIO('''Content-Type: text/plain;
66 charset="iso-8859-1"
67 From: Chef <chef@bork.bork.bork
68 To: issue_tracker@fill.me.in.
69 Cc: richard@test
70 Message-Id: <dummy_test_message_id>
71 Subject: Testing...
72
73 This is a test submission of a new issue.
74 ''')
75 handler = self.instance.MailGW(self.instance, self.db)
76 handler.main(message)
77 if os.path.exists(os.environ['SENDMAILDEBUG']):
78 error = open(os.environ['SENDMAILDEBUG']).read()
79 self.assertEqual('no error', error)
80
64 def testNewIssueAuthMsg(self): 81 def testNewIssueAuthMsg(self):
65 message = cStringIO.StringIO('''Content-Type: text/plain; 82 message = cStringIO.StringIO('''Content-Type: text/plain;
66 charset="iso-8859-1" 83 charset="iso-8859-1"
67 From: Chef <chef@bork.bork.bork 84 From: Chef <chef@bork.bork.bork
68 To: issue_tracker@fill.me.in. 85 To: issue_tracker@fill.me.in.
102 title: Testing... 119 title: Testing...
103 ___________________________________________________ 120 ___________________________________________________
104 "Roundup issue tracker" <issue_tracker@fill.me.in.> 121 "Roundup issue tracker" <issue_tracker@fill.me.in.>
105 http://some.useful.url/issue1 122 http://some.useful.url/issue1
106 ___________________________________________________ 123 ___________________________________________________
107 ''') 124 ''', 'Generated message not correct')
108 125
109 # BUG 126 # BUG
110 # def testMultipart(self): 127 # def testMultipart(self):
111 # '''With more than one part''' 128 # '''With more than one part'''
112 # see MultipartEnc tests: but if there is more than one part 129 # see MultipartEnc tests: but if there is more than one part
113 # we return a multipart/mixed and the boundary contains 130 # we return a multipart/mixed and the boundary contains
114 # the ip address of the test machine. 131 # the ip address of the test machine.
115 132
116 # BUG should test some binary attamchent too. 133 # BUG should test some binary attamchent too.
117 134
118 def testFollowup(self): 135 def testFollowup(self):
119 self.testNewIssue() 136 self.testNewIssue()
197 ___________________________________________________ 214 ___________________________________________________
198 "Roundup issue tracker" <issue_tracker@fill.me.in.> 215 "Roundup issue tracker" <issue_tracker@fill.me.in.>
199 http://some.useful.url/issue1 216 http://some.useful.url/issue1
200 ___________________________________________________ 217 ___________________________________________________
201 ''', 'Generated message not correct') 218 ''', 'Generated message not correct')
219
220 def testFollowupTitleMatch(self):
221 self.testNewIssue()
222 message = cStringIO.StringIO('''Content-Type: text/plain;
223 charset="iso-8859-1"
224 From: richard <richard@test>
225 To: issue_tracker@fill.me.in.
226 Message-Id: <followup_dummy_id>
227 In-Reply-To: <dummy_test_message_id>
228 Subject: Re: Testing... [assignedto=mary; nosy=john]
229
230 This is a followup
231 ''')
232 handler = self.instance.MailGW(self.instance, self.db)
233 handler.main(message)
234
235 self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(),
236 '''FROM: roundup-admin@fill.me.in.
237 TO: chef@bork.bork.bork, mary@test, john@test
238 Content-Type: text/plain
239 Subject: [issue1] Testing...
240 To: chef@bork.bork.bork, mary@test, john@test
241 From: richard <issue_tracker@fill.me.in.>
242 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.>
243 MIME-Version: 1.0
244 Message-Id: <followup_dummy_id>
245 In-Reply-To: <dummy_test_message_id>
246 X-Roundup-Name: Roundup issue tracker
247
248
249 richard <richard@test> added the comment:
250
251 This is a followup
252
253
254 ----------
255 assignedto: -> mary
256 nosy: +mary, john
257 status: unread -> chatting
258 ___________________________________________________
259 "Roundup issue tracker" <issue_tracker@fill.me.in.>
260 http://some.useful.url/issue1
261 ___________________________________________________
262 ''') #, 'Generated message not correct')
202 263
203 def testEnc01(self): 264 def testEnc01(self):
204 self.testNewIssue() 265 self.testNewIssue()
205 message = cStringIO.StringIO('''Content-Type: text/plain; 266 message = cStringIO.StringIO('''Content-Type: text/plain;
206 charset="iso-8859-1" 267 charset="iso-8859-1"
301 class ExtMailgwTestCase(MailgwTestCase): 362 class ExtMailgwTestCase(MailgwTestCase):
302 schema = 'extended' 363 schema = 'extended'
303 364
304 def suite(): 365 def suite():
305 l = [unittest.makeSuite(MailgwTestCase, 'test'), 366 l = [unittest.makeSuite(MailgwTestCase, 'test'),
306 unittest.makeSuite(ExtMailgwTestCase, 'test') 367 unittest.makeSuite(ExtMailgwTestCase, 'test')
307 ] 368 ]
308 return unittest.TestSuite(l) 369 return unittest.TestSuite(l)
309 370
310 371
311 # 372 #
312 # $Log: not supported by cvs2svn $ 373 # $Log: not supported by cvs2svn $
374 # Revision 1.11 2002/02/14 23:38:12 richard
375 # Fixed the unit tests for the mailgw re: the x-roundup-name header.
376 # Also made the test runner more user-friendly:
377 # ./run_tests - detect all tests in test/test_<name>.py and run them
378 # ./run_tests <name> - run only test/test_<name>.py
379 # eg ./run_tests mailgw - run the mailgw test from test/test_mailgw.py
380 #
313 # Revision 1.10 2002/02/12 08:08:55 grubert 381 # Revision 1.10 2002/02/12 08:08:55 grubert
314 # . Clean up mail handling, multipart handling. 382 # . Clean up mail handling, multipart handling.
315 # 383 #
316 # Revision 1.9 2002/02/05 14:15:29 grubert 384 # Revision 1.9 2002/02/05 14:15:29 grubert
317 # . respect encodings in non multipart messages. 385 # . respect encodings in non multipart messages.

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