Code

Fixed the unit tests for the new multilist controls in the mailgw
[roundup.git] / test / test_mailgw.py
1 #
2 # Copyright (c) 2001 Richard Jones, richard@bofh.asn.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 # This module is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 #
11 # $Id: test_mailgw.py,v 1.23 2002-07-14 02:02:43 richard Exp $
13 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib
15 # Note: Should parse emails according to RFC2822 instead of performing a
16 # literal string comparision.  Parsing the messages allows the tests to work for
17 # any legal serialization of an email.
18 #try :
19 #    import email
20 #except ImportError :
21 #    import rfc822 as email
23 from roundup.mailgw import MailGW
24 from roundup import init, instance
26 # TODO: make this output only enough equal lines for context, not all of
27 # them
28 class DiffHelper:
29     def compareStrings(self, s2, s1):
30         '''Note the reversal of s2 and s1 - difflib.SequenceMatcher wants
31            the first to be the "original" but in the calls in this file,
32            the second arg is the original. Ho hum.
33         '''
34         if s1 == s2:
35             return
37         # under python2.[12] we allow a difference of one trailing empty line.
38         if sys.version_info[0:2] == (2,1):
39             if s1+'\n' == s2:
40                 return
41         if sys.version_info[0:2] == (2,2):
42             if s1 == s2+'\n':
43                 return
44         
45         l1=s1.split('\n')
46         l2=s2.split('\n')
47         s = difflib.SequenceMatcher(None, l1, l2)
48         res = ['Generated message not correct (diff follows):']
49         for value, s1s, s1e, s2s, s2e in s.get_opcodes():
50             if value == 'equal':
51                 for i in range(s1s, s1e):
52                     res.append('  %s'%l1[i])
53             elif value == 'delete':
54                 for i in range(s1s, s1e):
55                     res.append('- %s'%l1[i])
56             elif value == 'insert':
57                 for i in range(s2s, s2e):
58                     res.append('+ %s'%l2[i])
59             elif value == 'replace':
60                 for i, j in zip(range(s1s, s1e), range(s2s, s2e)):
61                     res.append('- %s'%l1[i])
62                     res.append('+ %s'%l2[j])
64         raise AssertionError, '\n'.join(res)
66 class MailgwTestCase(unittest.TestCase, DiffHelper):
67     count = 0
68     schema = 'classic'
69     def setUp(self):
70         MailgwTestCase.count = MailgwTestCase.count + 1
71         self.dirname = '_test_mailgw_%s'%self.count
72         try:
73             shutil.rmtree(self.dirname)
74         except OSError, error:
75             if error.errno not in (errno.ENOENT, errno.ESRCH): raise
76         # create the instance
77         init.install(self.dirname, 'classic', 'anydbm')
78         init.initialise(self.dirname, 'sekrit')
79         # check we can load the package
80         self.instance = instance.open(self.dirname)
81         # and open the database
82         self.db = self.instance.open('sekrit')
83         self.db.user.create(username='Chef', address='chef@bork.bork.bork')
84         self.db.user.create(username='richard', address='richard@test')
85         self.db.user.create(username='mary', address='mary@test')
86         self.db.user.create(username='john', address='john@test',
87             alternate_addresses='jondoe@test\njohn.doe@test')
89     def tearDown(self):
90         if os.path.exists(os.environ['SENDMAILDEBUG']):
91             os.remove(os.environ['SENDMAILDEBUG'])
92         try:
93             shutil.rmtree(self.dirname)
94         except OSError, error:
95             if error.errno not in (errno.ENOENT, errno.ESRCH): raise
97     def doNewIssue(self):
98         message = cStringIO.StringIO('''Content-Type: text/plain;
99   charset="iso-8859-1"
100 From: Chef <chef@bork.bork.bork>
101 To: issue_tracker@your.tracker.email.domain.example
102 Cc: richard@test
103 Message-Id: <dummy_test_message_id>
104 Subject: [issue] Testing...
106 This is a test submission of a new issue.
107 ''')
108         handler = self.instance.MailGW(self.instance, self.db)
109         handler.trapExceptions = 0
110         nodeid = handler.main(message)
111         if os.path.exists(os.environ['SENDMAILDEBUG']):
112             error = open(os.environ['SENDMAILDEBUG']).read()
113             self.assertEqual('no error', error)
114         l = self.db.issue.get(nodeid, 'nosy')
115         l.sort()
116         self.assertEqual(l, ['2', '3'])
118     def testNewIssue(self):
119         self.doNewIssue()
121     def testNewIssueNosy(self):
122         self.instance.ADD_AUTHOR_TO_NOSY = 'yes'
123         message = cStringIO.StringIO('''Content-Type: text/plain;
124   charset="iso-8859-1"
125 From: Chef <chef@bork.bork.bork>
126 To: issue_tracker@your.tracker.email.domain.example
127 Cc: richard@test
128 Message-Id: <dummy_test_message_id>
129 Subject: [issue] Testing...
131 This is a test submission of a new issue.
132 ''')
133         handler = self.instance.MailGW(self.instance, self.db)
134         handler.trapExceptions = 0
135         nodeid = handler.main(message)
136         if os.path.exists(os.environ['SENDMAILDEBUG']):
137             error = open(os.environ['SENDMAILDEBUG']).read()
138             self.assertEqual('no error', error)
139         l = self.db.issue.get(nodeid, 'nosy')
140         l.sort()
141         self.assertEqual(l, ['2', '3'])
143     def testAlternateAddress(self):
144         message = cStringIO.StringIO('''Content-Type: text/plain;
145   charset="iso-8859-1"
146 From: John Doe <john.doe@test>
147 To: issue_tracker@your.tracker.email.domain.example
148 Message-Id: <dummy_test_message_id>
149 Subject: [issue] Testing...
151 This is a test submission of a new issue.
152 ''')
153         userlist = self.db.user.list()
154         handler = self.instance.MailGW(self.instance, self.db)
155         handler.trapExceptions = 0
156         handler.main(message)
157         if os.path.exists(os.environ['SENDMAILDEBUG']):
158             error = open(os.environ['SENDMAILDEBUG']).read()
159             self.assertEqual('no error', error)
160         self.assertEqual(userlist, self.db.user.list(),
161             "user created when it shouldn't have been")
163     def testNewIssueNoClass(self):
164         message = cStringIO.StringIO('''Content-Type: text/plain;
165   charset="iso-8859-1"
166 From: Chef <chef@bork.bork.bork>
167 To: issue_tracker@your.tracker.email.domain.example
168 Cc: richard@test
169 Message-Id: <dummy_test_message_id>
170 Subject: Testing...
172 This is a test submission of a new issue.
173 ''')
174         handler = self.instance.MailGW(self.instance, self.db)
175         handler.trapExceptions = 0
176         handler.main(message)
177         if os.path.exists(os.environ['SENDMAILDEBUG']):
178             error = open(os.environ['SENDMAILDEBUG']).read()
179             self.assertEqual('no error', error)
181     def testNewIssueAuthMsg(self):
182         message = cStringIO.StringIO('''Content-Type: text/plain;
183   charset="iso-8859-1"
184 From: Chef <chef@bork.bork.bork>
185 To: issue_tracker@your.tracker.email.domain.example
186 Message-Id: <dummy_test_message_id>
187 Subject: [issue] Testing... [nosy=mary; assignedto=richard]
189 This is a test submission of a new issue.
190 ''')
191         handler = self.instance.MailGW(self.instance, self.db)
192         handler.trapExceptions = 0
193         # TODO: fix the damn config - this is apalling
194         self.db.config.MESSAGES_TO_AUTHOR = 'yes'
195         handler.main(message)
197         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
198 '''FROM: roundup-admin@your.tracker.email.domain.example
199 TO: chef@bork.bork.bork, mary@test, richard@test
200 Content-Type: text/plain
201 Subject: [issue1] Testing...
202 To: chef@bork.bork.bork, mary@test, richard@test
203 From: "Chef" <issue_tracker@your.tracker.email.domain.example>
204 Reply-To: "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
205 MIME-Version: 1.0
206 Message-Id: <dummy_test_message_id>
207 X-Roundup-Name: Roundup issue tracker
208 Content-Transfer-Encoding: quoted-printable
211 New submission from Chef <chef@bork.bork.bork>:
213 This is a test submission of a new issue.
216 ----------
217 assignedto: richard
218 messages: 1
219 nosy: Chef, mary, richard
220 status: unread
221 title: Testing...
222 _________________________________________________________________________
223 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
224 http://your.tracker.url.example/issue1
225 _________________________________________________________________________
226 ''')
228     # BUG
229     # def testMultipart(self):
230     #         '''With more than one part'''
231     #        see MultipartEnc tests: but if there is more than one part
232     #        we return a multipart/mixed and the boundary contains
233     #        the ip address of the test machine. 
235     # BUG should test some binary attamchent too.
237     def testSimpleFollowup(self):
238         self.doNewIssue()
239         message = cStringIO.StringIO('''Content-Type: text/plain;
240   charset="iso-8859-1"
241 From: mary <mary@test>
242 To: issue_tracker@your.tracker.email.domain.example
243 Message-Id: <followup_dummy_id>
244 In-Reply-To: <dummy_test_message_id>
245 Subject: [issue1] Testing...
247 This is a second followup
248 ''')
249         handler = self.instance.MailGW(self.instance, self.db)
250         handler.trapExceptions = 0
251         handler.main(message)
252         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
253 '''FROM: roundup-admin@your.tracker.email.domain.example
254 TO: chef@bork.bork.bork, richard@test
255 Content-Type: text/plain
256 Subject: [issue1] Testing...
257 To: chef@bork.bork.bork, richard@test
258 From: "mary" <issue_tracker@your.tracker.email.domain.example>
259 Reply-To: "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
260 MIME-Version: 1.0
261 Message-Id: <followup_dummy_id>
262 In-Reply-To: <dummy_test_message_id>
263 X-Roundup-Name: Roundup issue tracker
264 Content-Transfer-Encoding: quoted-printable
267 mary <mary@test> added the comment:
269 This is a second followup
272 ----------
273 status: unread -> chatting
274 _________________________________________________________________________
275 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
276 http://your.tracker.url.example/issue1
277 _________________________________________________________________________
278 ''')
280     def testFollowup(self):
281         self.doNewIssue()
283         message = cStringIO.StringIO('''Content-Type: text/plain;
284   charset="iso-8859-1"
285 From: richard <richard@test>
286 To: issue_tracker@your.tracker.email.domain.example
287 Message-Id: <followup_dummy_id>
288 In-Reply-To: <dummy_test_message_id>
289 Subject: [issue1] Testing... [assignedto=mary; nosy=+john]
291 This is a followup
292 ''')
293         handler = self.instance.MailGW(self.instance, self.db)
294         handler.trapExceptions = 0
295         handler.main(message)
296         l = self.db.issue.get('1', 'nosy')
297         l.sort()
298         self.assertEqual(l, ['2', '3', '4', '5'])
300         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
301 '''FROM: roundup-admin@your.tracker.email.domain.example
302 TO: chef@bork.bork.bork, john@test, mary@test
303 Content-Type: text/plain
304 Subject: [issue1] Testing...
305 To: chef@bork.bork.bork, john@test, mary@test
306 From: "richard" <issue_tracker@your.tracker.email.domain.example>
307 Reply-To: "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
308 MIME-Version: 1.0
309 Message-Id: <followup_dummy_id>
310 In-Reply-To: <dummy_test_message_id>
311 X-Roundup-Name: Roundup issue tracker
312 Content-Transfer-Encoding: quoted-printable
315 richard <richard@test> added the comment:
317 This is a followup
320 ----------
321 assignedto:  -> mary
322 nosy: +mary, john
323 status: unread -> chatting
324 _________________________________________________________________________
325 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
326 http://your.tracker.url.example/issue1
327 _________________________________________________________________________
328 ''')
330     def testFollowupTitleMatch(self):
331         self.doNewIssue()
332         message = cStringIO.StringIO('''Content-Type: text/plain;
333   charset="iso-8859-1"
334 From: richard <richard@test>
335 To: issue_tracker@your.tracker.email.domain.example
336 Message-Id: <followup_dummy_id>
337 In-Reply-To: <dummy_test_message_id>
338 Subject: Re: Testing... [assignedto=mary; nosy=+john]
340 This is a followup
341 ''')
342         handler = self.instance.MailGW(self.instance, self.db)
343         handler.trapExceptions = 0
344         handler.main(message)
346         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
347 '''FROM: roundup-admin@your.tracker.email.domain.example
348 TO: chef@bork.bork.bork, john@test, mary@test
349 Content-Type: text/plain
350 Subject: [issue1] Testing...
351 To: chef@bork.bork.bork, john@test, mary@test
352 From: "richard" <issue_tracker@your.tracker.email.domain.example>
353 Reply-To: "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
354 MIME-Version: 1.0
355 Message-Id: <followup_dummy_id>
356 In-Reply-To: <dummy_test_message_id>
357 X-Roundup-Name: Roundup issue tracker
358 Content-Transfer-Encoding: quoted-printable
361 richard <richard@test> added the comment:
363 This is a followup
366 ----------
367 assignedto:  -> mary
368 nosy: +mary, john
369 status: unread -> chatting
370 _________________________________________________________________________
371 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
372 http://your.tracker.url.example/issue1
373 _________________________________________________________________________
374 ''')
376     def testFollowupNosyAuthor(self):
377         self.doNewIssue()
378         self.db.config.ADD_AUTHOR_TO_NOSY = self.instance.ADD_AUTHOR_TO_NOSY = 'yes'
379         message = cStringIO.StringIO('''Content-Type: text/plain;
380   charset="iso-8859-1"
381 From: john@test
382 To: issue_tracker@your.tracker.email.domain.example
383 Message-Id: <followup_dummy_id>
384 In-Reply-To: <dummy_test_message_id>
385 Subject: [issue1] Testing...
387 This is a followup
388 ''')
389         handler = self.instance.MailGW(self.instance, self.db)
390         handler.trapExceptions = 0
391         handler.main(message)
393         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
394 '''FROM: roundup-admin@your.tracker.email.domain.example
395 TO: chef@bork.bork.bork, richard@test
396 Content-Type: text/plain
397 Subject: [issue1] Testing...
398 To: chef@bork.bork.bork, richard@test
399 From: "john" <issue_tracker@your.tracker.email.domain.example>
400 Reply-To: "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
401 MIME-Version: 1.0
402 Message-Id: <followup_dummy_id>
403 In-Reply-To: <dummy_test_message_id>
404 X-Roundup-Name: Roundup issue tracker
405 Content-Transfer-Encoding: quoted-printable
408 john <john@test> added the comment:
410 This is a followup
413 ----------
414 nosy: +john
415 status: unread -> chatting
416 _________________________________________________________________________
417 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
418 http://your.tracker.url.example/issue1
419 _________________________________________________________________________
421 ''')
423     def testFollowupNosyRecipients(self):
424         self.doNewIssue()
425         self.db.config.ADD_RECIPIENTS_TO_NOSY = self.instance.ADD_RECIPIENTS_TO_NOSY = 'yes'
426         message = cStringIO.StringIO('''Content-Type: text/plain;
427   charset="iso-8859-1"
428 From: richard@test
429 To: issue_tracker@your.tracker.email.domain.example
430 Cc: john@test
431 Message-Id: <followup_dummy_id>
432 In-Reply-To: <dummy_test_message_id>
433 Subject: [issue1] Testing...
435 This is a followup
436 ''')
437         handler = self.instance.MailGW(self.instance, self.db)
438         handler.trapExceptions = 0
439         handler.main(message)
441         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
442 '''FROM: roundup-admin@your.tracker.email.domain.example
443 TO: chef@bork.bork.bork
444 Content-Type: text/plain
445 Subject: [issue1] Testing...
446 To: chef@bork.bork.bork
447 From: "richard" <issue_tracker@your.tracker.email.domain.example>
448 Reply-To: "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
449 MIME-Version: 1.0
450 Message-Id: <followup_dummy_id>
451 In-Reply-To: <dummy_test_message_id>
452 X-Roundup-Name: Roundup issue tracker
453 Content-Transfer-Encoding: quoted-printable
456 richard <richard@test> added the comment:
458 This is a followup
461 ----------
462 nosy: +john
463 status: unread -> chatting
464 _________________________________________________________________________
465 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
466 http://your.tracker.url.example/issue1
467 _________________________________________________________________________
469 ''')
471     def testFollowupNosyAuthorAndCopy(self):
472         self.doNewIssue()
473         self.db.config.ADD_AUTHOR_TO_NOSY = self.instance.ADD_AUTHOR_TO_NOSY = 'yes'
474         self.db.config.MESSAGES_TO_AUTHOR = 'yes'
475         message = cStringIO.StringIO('''Content-Type: text/plain;
476   charset="iso-8859-1"
477 From: john@test
478 To: issue_tracker@your.tracker.email.domain.example
479 Message-Id: <followup_dummy_id>
480 In-Reply-To: <dummy_test_message_id>
481 Subject: [issue1] Testing...
483 This is a followup
484 ''')
485         handler = self.instance.MailGW(self.instance, self.db)
486         handler.trapExceptions = 0
487         handler.main(message)
489         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
490 '''FROM: roundup-admin@your.tracker.email.domain.example
491 TO: chef@bork.bork.bork, john@test, richard@test
492 Content-Type: text/plain
493 Subject: [issue1] Testing...
494 To: chef@bork.bork.bork, john@test, richard@test
495 From: "john" <issue_tracker@your.tracker.email.domain.example>
496 Reply-To: "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
497 MIME-Version: 1.0
498 Message-Id: <followup_dummy_id>
499 In-Reply-To: <dummy_test_message_id>
500 X-Roundup-Name: Roundup issue tracker
501 Content-Transfer-Encoding: quoted-printable
504 john <john@test> added the comment:
506 This is a followup
509 ----------
510 nosy: +john
511 status: unread -> chatting
512 _________________________________________________________________________
513 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
514 http://your.tracker.url.example/issue1
515 _________________________________________________________________________
517 ''')
519     def testFollowupNoNosyAuthor(self):
520         self.doNewIssue()
521         self.instance.ADD_AUTHOR_TO_NOSY = 'no'
522         message = cStringIO.StringIO('''Content-Type: text/plain;
523   charset="iso-8859-1"
524 From: john@test
525 To: issue_tracker@your.tracker.email.domain.example
526 Message-Id: <followup_dummy_id>
527 In-Reply-To: <dummy_test_message_id>
528 Subject: [issue1] Testing...
530 This is a followup
531 ''')
532         handler = self.instance.MailGW(self.instance, self.db)
533         handler.trapExceptions = 0
534         handler.main(message)
536         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
537 '''FROM: roundup-admin@your.tracker.email.domain.example
538 TO: chef@bork.bork.bork, richard@test
539 Content-Type: text/plain
540 Subject: [issue1] Testing...
541 To: chef@bork.bork.bork, richard@test
542 From: "john" <issue_tracker@your.tracker.email.domain.example>
543 Reply-To: "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
544 MIME-Version: 1.0
545 Message-Id: <followup_dummy_id>
546 In-Reply-To: <dummy_test_message_id>
547 X-Roundup-Name: Roundup issue tracker
548 Content-Transfer-Encoding: quoted-printable
551 john <john@test> added the comment:
553 This is a followup
556 ----------
557 status: unread -> chatting
558 _________________________________________________________________________
559 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
560 http://your.tracker.url.example/issue1
561 _________________________________________________________________________
563 ''')
565     def testFollowupNoNosyRecipients(self):
566         self.doNewIssue()
567         self.instance.ADD_RECIPIENTS_TO_NOSY = 'no'
568         message = cStringIO.StringIO('''Content-Type: text/plain;
569   charset="iso-8859-1"
570 From: richard@test
571 To: issue_tracker@your.tracker.email.domain.example
572 Cc: john@test
573 Message-Id: <followup_dummy_id>
574 In-Reply-To: <dummy_test_message_id>
575 Subject: [issue1] Testing...
577 This is a followup
578 ''')
579         handler = self.instance.MailGW(self.instance, self.db)
580         handler.trapExceptions = 0
581         handler.main(message)
583         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
584 '''FROM: roundup-admin@your.tracker.email.domain.example
585 TO: chef@bork.bork.bork
586 Content-Type: text/plain
587 Subject: [issue1] Testing...
588 To: chef@bork.bork.bork
589 From: "richard" <issue_tracker@your.tracker.email.domain.example>
590 Reply-To: "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
591 MIME-Version: 1.0
592 Message-Id: <followup_dummy_id>
593 In-Reply-To: <dummy_test_message_id>
594 X-Roundup-Name: Roundup issue tracker
595 Content-Transfer-Encoding: quoted-printable
598 richard <richard@test> added the comment:
600 This is a followup
603 ----------
604 status: unread -> chatting
605 _________________________________________________________________________
606 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
607 http://your.tracker.url.example/issue1
608 _________________________________________________________________________
610 ''')
612     def testNosyRemove(self):
613         self.doNewIssue()
615         message = cStringIO.StringIO('''Content-Type: text/plain;
616   charset="iso-8859-1"
617 From: richard <richard@test>
618 To: issue_tracker@your.tracker.email.domain.example
619 Message-Id: <followup_dummy_id>
620 In-Reply-To: <dummy_test_message_id>
621 Subject: [issue1] Testing... [nosy=-richard]
623 ''')
624         handler = self.instance.MailGW(self.instance, self.db)
625         handler.trapExceptions = 0
626         handler.main(message)
627         l = self.db.issue.get('1', 'nosy')
628         l.sort()
629         self.assertEqual(l, ['2'])
631         # NO NOSY MESSAGE SHOULD BE SENT!
632         self.assert_(not os.path.exists(os.environ['SENDMAILDEBUG']))
634     def testEnc01(self):
635         self.doNewIssue()
636         message = cStringIO.StringIO('''Content-Type: text/plain;
637   charset="iso-8859-1"
638 From: mary <mary@test>
639 To: issue_tracker@your.tracker.email.domain.example
640 Message-Id: <followup_dummy_id>
641 In-Reply-To: <dummy_test_message_id>
642 Subject: [issue1] Testing...
643 Content-Type: text/plain;
644         charset="iso-8859-1"
645 Content-Transfer-Encoding: quoted-printable
647 A message with encoding (encoded oe =F6)
649 ''')
650         handler = self.instance.MailGW(self.instance, self.db)
651         handler.trapExceptions = 0
652         handler.main(message)
653         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
654 '''FROM: roundup-admin@your.tracker.email.domain.example
655 TO: chef@bork.bork.bork, richard@test
656 Content-Type: text/plain
657 Subject: [issue1] Testing...
658 To: chef@bork.bork.bork, richard@test
659 From: "mary" <issue_tracker@your.tracker.email.domain.example>
660 Reply-To: "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
661 MIME-Version: 1.0
662 Message-Id: <followup_dummy_id>
663 In-Reply-To: <dummy_test_message_id>
664 X-Roundup-Name: Roundup issue tracker
665 Content-Transfer-Encoding: quoted-printable
668 mary <mary@test> added the comment:
670 A message with encoding (encoded oe =F6)
672 ----------
673 status: unread -> chatting
674 _________________________________________________________________________
675 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
676 http://your.tracker.url.example/issue1
677 _________________________________________________________________________
678 ''')
681     def testMultipartEnc01(self):
682         self.doNewIssue()
683         message = cStringIO.StringIO('''Content-Type: text/plain;
684   charset="iso-8859-1"
685 From: mary <mary@test>
686 To: issue_tracker@your.tracker.email.domain.example
687 Message-Id: <followup_dummy_id>
688 In-Reply-To: <dummy_test_message_id>
689 Subject: [issue1] Testing...
690 Content-Type: multipart/mixed;
691         boundary="----_=_NextPart_000_01"
693 This message is in MIME format. Since your mail reader does not understand
694 this format, some or all of this message may not be legible.
696 ------_=_NextPart_000_01
697 Content-Type: text/plain;
698         charset="iso-8859-1"
699 Content-Transfer-Encoding: quoted-printable
701 A message with first part encoded (encoded oe =F6)
703 ''')
704         handler = self.instance.MailGW(self.instance, self.db)
705         handler.trapExceptions = 0
706         handler.main(message)
707         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
708 '''FROM: roundup-admin@your.tracker.email.domain.example
709 TO: chef@bork.bork.bork, richard@test
710 Content-Type: text/plain
711 Subject: [issue1] Testing...
712 To: chef@bork.bork.bork, richard@test
713 From: "mary" <issue_tracker@your.tracker.email.domain.example>
714 Reply-To: "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
715 MIME-Version: 1.0
716 Message-Id: <followup_dummy_id>
717 In-Reply-To: <dummy_test_message_id>
718 X-Roundup-Name: Roundup issue tracker
719 Content-Transfer-Encoding: quoted-printable
722 mary <mary@test> added the comment:
724 A message with first part encoded (encoded oe =F6)
726 ----------
727 status: unread -> chatting
728 _________________________________________________________________________
729 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
730 http://your.tracker.url.example/issue1
731 _________________________________________________________________________
732 ''')
734 class ExtMailgwTestCase(MailgwTestCase):
735     schema = 'extended'
737 def suite():
738     l = [unittest.makeSuite(MailgwTestCase),
739          unittest.makeSuite(ExtMailgwTestCase, 'test')
740     ]
741     return unittest.TestSuite(l)
745 # $Log: not supported by cvs2svn $
746 # Revision 1.22  2002/07/09 01:21:24  richard
747 # Added ability for unit tests to turn off exception handling in mailgw so
748 # that exceptions are reported earlier (and hence make sense).
750 # Revision 1.21  2002/06/18 03:59:59  dman13
751 # Updated message strings to match the RFC822 address quoting performed
752 # by the 'email' and 'rfc822' modules.  The verification really should
753 # use a RFC2822 message parser rather than literal string comparisions
754 # to allow for legal variations in messages.
756 # Revision 1.20  2002/05/29 01:16:17  richard
757 # Sorry about this huge checkin! It's fixing a lot of related stuff in one go
758 # though.
760 # . #541941 ] changing multilink properties by mail
761 # . #526730 ] search for messages capability
762 # . #505180 ] split MailGW.handle_Message
763 #   - also changed cgi client since it was duplicating the functionality
764 # . build htmlbase if tests are run using CVS checkout (removed note from
765 #   installation.txt)
766 # . don't create an empty message on email issue creation if the email is empty
768 # Revision 1.19  2002/05/23 04:26:05  richard
769 # 'I must run unit tests before committing\n' * 100
771 # Revision 1.18  2002/05/15 03:27:16  richard
772 #  . fixed SCRIPT_NAME in ZRoundup for instances not at top level of Zope
773 #    (thanks dman)
774 #  . fixed some sorting issues that were breaking some unit tests under py2.2
775 #  . mailgw test output dir was confusing the init test (but only on 2.2 *shrug*)
777 # fixed bug in the init unit test that meant only the bsddb test ran if it
778 # could (it clobbered the anydbm test)
780 # Revision 1.17  2002/05/02 07:56:34  richard
781 # . added option to automatically add the authors and recipients of messages
782 #   to the nosy lists with the options ADD_AUTHOR_TO_NOSY (default 'new') and
783 #   ADD_RECIPIENTS_TO_NOSY (default 'new'). These settings emulate the current
784 #   behaviour. Setting them to 'yes' will add the author/recipients to the nosy
785 #   on messages that create issues and followup messages.
786 # . added missing documentation for a few of the config option values
788 # Revision 1.16  2002/03/19 21:58:11  grubert
789 #  . for python2.1 test_mailgw compareString allows an extra trailing empty line (for quopri.
791 # Revision 1.15  2002/03/19 06:37:00  richard
792 # Made the email checking spit out a diff - much easier to spot the problem!
794 # Revision 1.14  2002/03/18 18:32:00  rochecompaan
795 # All messages sent to the nosy list are now encoded as quoted-printable.
797 # Revision 1.13  2002/02/15 07:08:45  richard
798 #  . Alternate email addresses are now available for users. See the MIGRATION
799 #    file for info on how to activate the feature.
801 # Revision 1.12  2002/02/15 00:13:38  richard
802 #  . #503204 ] mailgw needs a default class
803 #     - partially done - the setting of additional properties can wait for a
804 #       better configuration system.
806 # Revision 1.11  2002/02/14 23:38:12  richard
807 # Fixed the unit tests for the mailgw re: the x-roundup-name header.
808 # Also made the test runner more user-friendly:
809 #   ./run_tests            - detect all tests in test/test_<name>.py and run them
810 #   ./run_tests <name>     - run only test/test_<name>.py
811 # eg ./run_tests mailgw    - run the mailgw test from test/test_mailgw.py
813 # Revision 1.10  2002/02/12 08:08:55  grubert
814 #  . Clean up mail handling, multipart handling.
816 # Revision 1.9  2002/02/05 14:15:29  grubert
817 #  . respect encodings in non multipart messages.
819 # Revision 1.8  2002/02/04 09:40:21  grubert
820 #  . add test for multipart messages with first part being encoded.
822 # Revision 1.7  2002/01/22 11:54:45  rochecompaan
823 # Fixed status change in mail gateway.
825 # Revision 1.6  2002/01/21 10:05:48  rochecompaan
826 # Feature:
827 #  . the mail gateway now responds with an error message when invalid
828 #    values for arguments are specified for link or multilink properties
829 #  . modified unit test to check nosy and assignedto when specified as
830 #    arguments
832 # Fixed:
833 #  . fixed setting nosy as argument in subject line
835 # Revision 1.5  2002/01/15 00:12:40  richard
836 # #503340 ] creating issue with [asignedto=p.ohly]
838 # Revision 1.4  2002/01/14 07:12:15  richard
839 # removed file writing from tests...
841 # Revision 1.3  2002/01/14 02:20:15  richard
842 #  . changed all config accesses so they access either the instance or the
843 #    config attriubute on the db. This means that all config is obtained from
844 #    instance_config instead of the mish-mash of classes. This will make
845 #    switching to a ConfigParser setup easier too, I hope.
847 # At a minimum, this makes migration a _little_ easier (a lot easier in the
848 # 0.5.0 switch, I hope!)
850 # Revision 1.2  2002/01/11 23:22:29  richard
851 #  . #502437 ] rogue reactor and unittest
852 #    in short, the nosy reactor was modifying the nosy list. That code had
853 #    been there for a long time, and I suspsect it was there because we
854 #    weren't generating the nosy list correctly in other places of the code.
855 #    We're now doing that, so the nosy-modifying code can go away from the
856 #    nosy reactor.
858 # Revision 1.1  2002/01/02 02:31:38  richard
859 # Sorry for the huge checkin message - I was only intending to implement #496356
860 # but I found a number of places where things had been broken by transactions:
861 #  . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename
862 #    for _all_ roundup-generated smtp messages to be sent to.
863 #  . the transaction cache had broken the roundupdb.Class set() reactors
864 #  . newly-created author users in the mailgw weren't being committed to the db
866 # Stuff that made it into CHANGES.txt (ie. the stuff I was actually working
867 # on when I found that stuff :):
868 #  . #496356 ] Use threading in messages
869 #  . detectors were being registered multiple times
870 #  . added tests for mailgw
871 #  . much better attaching of erroneous messages in the mail gateway
876 # vim: set filetype=python ts=4 sw=4 et si