Code

93a1f8fb5b955affa47a0ed2c928b764fa0defb6
[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.20 2002-05-29 01:16:17 richard Exp $
13 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib
15 from roundup.mailgw import MailGW
16 from roundup import init, instance
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
29         # under python2.[12] we allow a difference of one trailing empty line.
30         if sys.version_info[0:2] == (2,1):
31             if s1+'\n' == s2:
32                 return
33         if sys.version_info[0:2] == (2,2):
34             if s1 == s2+'\n':
35                 return
36         
37         l1=s1.split('\n')
38         l2=s2.split('\n')
39         s = difflib.SequenceMatcher(None, l1, l2)
40         res = ['Generated message not correct (diff follows):']
41         for value, s1s, s1e, s2s, s2e in s.get_opcodes():
42             if value == 'equal':
43                 for i in range(s1s, s1e):
44                     res.append('  %s'%l1[i])
45             elif value == 'delete':
46                 for i in range(s1s, s1e):
47                     res.append('- %s'%l1[i])
48             elif value == 'insert':
49                 for i in range(s2s, s2e):
50                     res.append('+ %s'%l2[i])
51             elif value == 'replace':
52                 for i, j in zip(range(s1s, s1e), range(s2s, s2e)):
53                     res.append('- %s'%l1[i])
54                     res.append('+ %s'%l2[j])
56         raise AssertionError, '\n'.join(res)
58 class MailgwTestCase(unittest.TestCase, DiffHelper):
59     count = 0
60     schema = 'classic'
61     def setUp(self):
62         MailgwTestCase.count = MailgwTestCase.count + 1
63         self.dirname = '_test_mailgw_%s'%self.count
64         try:
65             shutil.rmtree(self.dirname)
66         except OSError, error:
67             if error.errno not in (errno.ENOENT, errno.ESRCH): raise
68         # create the instance
69         init.install(self.dirname, 'classic', 'anydbm')
70         init.initialise(self.dirname, 'sekrit')
71         # check we can load the package
72         self.instance = instance.open(self.dirname)
73         # and open the database
74         self.db = self.instance.open('sekrit')
75         self.db.user.create(username='Chef', address='chef@bork.bork.bork')
76         self.db.user.create(username='richard', address='richard@test')
77         self.db.user.create(username='mary', address='mary@test')
78         self.db.user.create(username='john', address='john@test',
79             alternate_addresses='jondoe@test\njohn.doe@test')
81     def tearDown(self):
82         if os.path.exists(os.environ['SENDMAILDEBUG']):
83             os.remove(os.environ['SENDMAILDEBUG'])
84         try:
85             shutil.rmtree(self.dirname)
86         except OSError, error:
87             if error.errno not in (errno.ENOENT, errno.ESRCH): raise
89     def doNewIssue(self):
90         message = cStringIO.StringIO('''Content-Type: text/plain;
91   charset="iso-8859-1"
92 From: Chef <chef@bork.bork.bork
93 To: issue_tracker@your.tracker.email.domain.example
94 Cc: richard@test
95 Message-Id: <dummy_test_message_id>
96 Subject: [issue] Testing...
98 This is a test submission of a new issue.
99 ''')
100         handler = self.instance.MailGW(self.instance, self.db)
101         nodeid = handler.main(message)
102         if os.path.exists(os.environ['SENDMAILDEBUG']):
103             error = open(os.environ['SENDMAILDEBUG']).read()
104             self.assertEqual('no error', error)
105         l = self.db.issue.get(nodeid, 'nosy')
106         l.sort()
107         self.assertEqual(l, ['2', '3'])
109     def testNewIssue(self):
110         self.doNewIssue()
112     def testNewIssueNosy(self):
113         self.instance.ADD_AUTHOR_TO_NOSY = 'yes'
114         message = cStringIO.StringIO('''Content-Type: text/plain;
115   charset="iso-8859-1"
116 From: Chef <chef@bork.bork.bork
117 To: issue_tracker@your.tracker.email.domain.example
118 Cc: richard@test
119 Message-Id: <dummy_test_message_id>
120 Subject: [issue] Testing...
122 This is a test submission of a new issue.
123 ''')
124         handler = self.instance.MailGW(self.instance, self.db)
125         nodeid = handler.main(message)
126         if os.path.exists(os.environ['SENDMAILDEBUG']):
127             error = open(os.environ['SENDMAILDEBUG']).read()
128             self.assertEqual('no error', error)
129         l = self.db.issue.get(nodeid, 'nosy')
130         l.sort()
131         self.assertEqual(l, ['2', '3'])
133     def testAlternateAddress(self):
134         message = cStringIO.StringIO('''Content-Type: text/plain;
135   charset="iso-8859-1"
136 From: John Doe <john.doe@test>
137 To: issue_tracker@your.tracker.email.domain.example
138 Message-Id: <dummy_test_message_id>
139 Subject: [issue] Testing...
141 This is a test submission of a new issue.
142 ''')
143         userlist = self.db.user.list()
144         handler = self.instance.MailGW(self.instance, self.db)
145         handler.main(message)
146         if os.path.exists(os.environ['SENDMAILDEBUG']):
147             error = open(os.environ['SENDMAILDEBUG']).read()
148             self.assertEqual('no error', error)
149         self.assertEqual(userlist, self.db.user.list(),
150             "user created when it shouldn't have been")
152     def testNewIssueNoClass(self):
153         message = cStringIO.StringIO('''Content-Type: text/plain;
154   charset="iso-8859-1"
155 From: Chef <chef@bork.bork.bork
156 To: issue_tracker@your.tracker.email.domain.example
157 Cc: richard@test
158 Message-Id: <dummy_test_message_id>
159 Subject: Testing...
161 This is a test submission of a new issue.
162 ''')
163         handler = self.instance.MailGW(self.instance, self.db)
164         handler.main(message)
165         if os.path.exists(os.environ['SENDMAILDEBUG']):
166             error = open(os.environ['SENDMAILDEBUG']).read()
167             self.assertEqual('no error', error)
169     def testNewIssueAuthMsg(self):
170         message = cStringIO.StringIO('''Content-Type: text/plain;
171   charset="iso-8859-1"
172 From: Chef <chef@bork.bork.bork
173 To: issue_tracker@your.tracker.email.domain.example
174 Message-Id: <dummy_test_message_id>
175 Subject: [issue] Testing... [nosy=mary; assignedto=richard]
177 This is a test submission of a new issue.
178 ''')
179         handler = self.instance.MailGW(self.instance, self.db)
180         # TODO: fix the damn config - this is apalling
181         self.db.config.MESSAGES_TO_AUTHOR = 'yes'
182         handler.main(message)
184         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
185 '''FROM: roundup-admin@your.tracker.email.domain.example
186 TO: chef@bork.bork.bork, mary@test, richard@test
187 Content-Type: text/plain
188 Subject: [issue1] Testing...
189 To: chef@bork.bork.bork, mary@test, richard@test
190 From: Chef <issue_tracker@your.tracker.email.domain.example>
191 Reply-To: Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
192 MIME-Version: 1.0
193 Message-Id: <dummy_test_message_id>
194 X-Roundup-Name: Roundup issue tracker
195 Content-Transfer-Encoding: quoted-printable
198 New submission from Chef <chef@bork.bork.bork>:
200 This is a test submission of a new issue.
203 ----------
204 assignedto: richard
205 messages: 1
206 nosy: Chef, mary, richard
207 status: unread
208 title: Testing...
209 _________________________________________________________________________
210 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
211 http://your.tracker.url.example/issue1
212 _________________________________________________________________________
213 ''')
215     # BUG
216     # def testMultipart(self):
217     #         '''With more than one part'''
218     #        see MultipartEnc tests: but if there is more than one part
219     #        we return a multipart/mixed and the boundary contains
220     #        the ip address of the test machine. 
222     # BUG should test some binary attamchent too.
224     def testSimpleFollowup(self):
225         self.doNewIssue()
226         message = cStringIO.StringIO('''Content-Type: text/plain;
227   charset="iso-8859-1"
228 From: mary <mary@test>
229 To: issue_tracker@your.tracker.email.domain.example
230 Message-Id: <followup_dummy_id>
231 In-Reply-To: <dummy_test_message_id>
232 Subject: [issue1] Testing...
234 This is a second followup
235 ''')
236         handler = self.instance.MailGW(self.instance, self.db)
237         handler.main(message)
238         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
239 '''FROM: roundup-admin@your.tracker.email.domain.example
240 TO: chef@bork.bork.bork, richard@test
241 Content-Type: text/plain
242 Subject: [issue1] Testing...
243 To: chef@bork.bork.bork, richard@test
244 From: mary <issue_tracker@your.tracker.email.domain.example>
245 Reply-To: Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
246 MIME-Version: 1.0
247 Message-Id: <followup_dummy_id>
248 In-Reply-To: <dummy_test_message_id>
249 X-Roundup-Name: Roundup issue tracker
250 Content-Transfer-Encoding: quoted-printable
253 mary <mary@test> added the comment:
255 This is a second followup
258 ----------
259 status: unread -> chatting
260 _________________________________________________________________________
261 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
262 http://your.tracker.url.example/issue1
263 _________________________________________________________________________
264 ''')
266     def testFollowup(self):
267         self.doNewIssue()
269         message = cStringIO.StringIO('''Content-Type: text/plain;
270   charset="iso-8859-1"
271 From: richard <richard@test>
272 To: issue_tracker@your.tracker.email.domain.example
273 Message-Id: <followup_dummy_id>
274 In-Reply-To: <dummy_test_message_id>
275 Subject: [issue1] Testing... [assignedto=mary; nosy=john]
277 This is a followup
278 ''')
279         handler = self.instance.MailGW(self.instance, self.db)
280         handler.main(message)
281         l = self.db.issue.get('1', 'nosy')
282         l.sort()
283         self.assertEqual(l, ['2', '3', '4', '5'])
285         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
286 '''FROM: roundup-admin@your.tracker.email.domain.example
287 TO: chef@bork.bork.bork, john@test, mary@test
288 Content-Type: text/plain
289 Subject: [issue1] Testing...
290 To: chef@bork.bork.bork, john@test, mary@test
291 From: richard <issue_tracker@your.tracker.email.domain.example>
292 Reply-To: Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
293 MIME-Version: 1.0
294 Message-Id: <followup_dummy_id>
295 In-Reply-To: <dummy_test_message_id>
296 X-Roundup-Name: Roundup issue tracker
297 Content-Transfer-Encoding: quoted-printable
300 richard <richard@test> added the comment:
302 This is a followup
305 ----------
306 assignedto:  -> mary
307 nosy: +mary, john
308 status: unread -> chatting
309 _________________________________________________________________________
310 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
311 http://your.tracker.url.example/issue1
312 _________________________________________________________________________
313 ''')
315     def testFollowupTitleMatch(self):
316         self.doNewIssue()
317         message = cStringIO.StringIO('''Content-Type: text/plain;
318   charset="iso-8859-1"
319 From: richard <richard@test>
320 To: issue_tracker@your.tracker.email.domain.example
321 Message-Id: <followup_dummy_id>
322 In-Reply-To: <dummy_test_message_id>
323 Subject: Re: Testing... [assignedto=mary; nosy=john]
325 This is a followup
326 ''')
327         handler = self.instance.MailGW(self.instance, self.db)
328         handler.main(message)
330         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
331 '''FROM: roundup-admin@your.tracker.email.domain.example
332 TO: chef@bork.bork.bork, john@test, mary@test
333 Content-Type: text/plain
334 Subject: [issue1] Testing...
335 To: chef@bork.bork.bork, john@test, mary@test
336 From: richard <issue_tracker@your.tracker.email.domain.example>
337 Reply-To: Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
338 MIME-Version: 1.0
339 Message-Id: <followup_dummy_id>
340 In-Reply-To: <dummy_test_message_id>
341 X-Roundup-Name: Roundup issue tracker
342 Content-Transfer-Encoding: quoted-printable
345 richard <richard@test> added the comment:
347 This is a followup
350 ----------
351 assignedto:  -> mary
352 nosy: +mary, john
353 status: unread -> chatting
354 _________________________________________________________________________
355 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
356 http://your.tracker.url.example/issue1
357 _________________________________________________________________________
358 ''')
360     def testFollowupNosyAuthor(self):
361         self.doNewIssue()
362         self.db.config.ADD_AUTHOR_TO_NOSY = self.instance.ADD_AUTHOR_TO_NOSY = 'yes'
363         message = cStringIO.StringIO('''Content-Type: text/plain;
364   charset="iso-8859-1"
365 From: john@test
366 To: issue_tracker@your.tracker.email.domain.example
367 Message-Id: <followup_dummy_id>
368 In-Reply-To: <dummy_test_message_id>
369 Subject: [issue1] Testing...
371 This is a followup
372 ''')
373         handler = self.instance.MailGW(self.instance, self.db)
374         handler.main(message)
376         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
377 '''FROM: roundup-admin@your.tracker.email.domain.example
378 TO: chef@bork.bork.bork, richard@test
379 Content-Type: text/plain
380 Subject: [issue1] Testing...
381 To: chef@bork.bork.bork, richard@test
382 From: john <issue_tracker@your.tracker.email.domain.example>
383 Reply-To: Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
384 MIME-Version: 1.0
385 Message-Id: <followup_dummy_id>
386 In-Reply-To: <dummy_test_message_id>
387 X-Roundup-Name: Roundup issue tracker
388 Content-Transfer-Encoding: quoted-printable
391 john <john@test> added the comment:
393 This is a followup
396 ----------
397 nosy: +john
398 status: unread -> chatting
399 _________________________________________________________________________
400 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
401 http://your.tracker.url.example/issue1
402 _________________________________________________________________________
404 ''')
406     def testFollowupNosyRecipients(self):
407         self.doNewIssue()
408         self.db.config.ADD_RECIPIENTS_TO_NOSY = self.instance.ADD_RECIPIENTS_TO_NOSY = 'yes'
409         message = cStringIO.StringIO('''Content-Type: text/plain;
410   charset="iso-8859-1"
411 From: richard@test
412 To: issue_tracker@your.tracker.email.domain.example
413 Cc: john@test
414 Message-Id: <followup_dummy_id>
415 In-Reply-To: <dummy_test_message_id>
416 Subject: [issue1] Testing...
418 This is a followup
419 ''')
420         handler = self.instance.MailGW(self.instance, self.db)
421         handler.main(message)
423         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
424 '''FROM: roundup-admin@your.tracker.email.domain.example
425 TO: chef@bork.bork.bork
426 Content-Type: text/plain
427 Subject: [issue1] Testing...
428 To: chef@bork.bork.bork
429 From: richard <issue_tracker@your.tracker.email.domain.example>
430 Reply-To: Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
431 MIME-Version: 1.0
432 Message-Id: <followup_dummy_id>
433 In-Reply-To: <dummy_test_message_id>
434 X-Roundup-Name: Roundup issue tracker
435 Content-Transfer-Encoding: quoted-printable
438 richard <richard@test> added the comment:
440 This is a followup
443 ----------
444 nosy: +john
445 status: unread -> chatting
446 _________________________________________________________________________
447 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
448 http://your.tracker.url.example/issue1
449 _________________________________________________________________________
451 ''')
453     def testFollowupNosyAuthorAndCopy(self):
454         self.doNewIssue()
455         self.db.config.ADD_AUTHOR_TO_NOSY = self.instance.ADD_AUTHOR_TO_NOSY = 'yes'
456         self.db.config.MESSAGES_TO_AUTHOR = 'yes'
457         message = cStringIO.StringIO('''Content-Type: text/plain;
458   charset="iso-8859-1"
459 From: john@test
460 To: issue_tracker@your.tracker.email.domain.example
461 Message-Id: <followup_dummy_id>
462 In-Reply-To: <dummy_test_message_id>
463 Subject: [issue1] Testing...
465 This is a followup
466 ''')
467         handler = self.instance.MailGW(self.instance, self.db)
468         handler.main(message)
470         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
471 '''FROM: roundup-admin@your.tracker.email.domain.example
472 TO: chef@bork.bork.bork, john@test, richard@test
473 Content-Type: text/plain
474 Subject: [issue1] Testing...
475 To: chef@bork.bork.bork, john@test, richard@test
476 From: john <issue_tracker@your.tracker.email.domain.example>
477 Reply-To: Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
478 MIME-Version: 1.0
479 Message-Id: <followup_dummy_id>
480 In-Reply-To: <dummy_test_message_id>
481 X-Roundup-Name: Roundup issue tracker
482 Content-Transfer-Encoding: quoted-printable
485 john <john@test> added the comment:
487 This is a followup
490 ----------
491 nosy: +john
492 status: unread -> chatting
493 _________________________________________________________________________
494 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
495 http://your.tracker.url.example/issue1
496 _________________________________________________________________________
498 ''')
500     def testFollowupNoNosyAuthor(self):
501         self.doNewIssue()
502         self.instance.ADD_AUTHOR_TO_NOSY = 'no'
503         message = cStringIO.StringIO('''Content-Type: text/plain;
504   charset="iso-8859-1"
505 From: john@test
506 To: issue_tracker@your.tracker.email.domain.example
507 Message-Id: <followup_dummy_id>
508 In-Reply-To: <dummy_test_message_id>
509 Subject: [issue1] Testing...
511 This is a followup
512 ''')
513         handler = self.instance.MailGW(self.instance, self.db)
514         handler.main(message)
516         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
517 '''FROM: roundup-admin@your.tracker.email.domain.example
518 TO: chef@bork.bork.bork, richard@test
519 Content-Type: text/plain
520 Subject: [issue1] Testing...
521 To: chef@bork.bork.bork, richard@test
522 From: john <issue_tracker@your.tracker.email.domain.example>
523 Reply-To: Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
524 MIME-Version: 1.0
525 Message-Id: <followup_dummy_id>
526 In-Reply-To: <dummy_test_message_id>
527 X-Roundup-Name: Roundup issue tracker
528 Content-Transfer-Encoding: quoted-printable
531 john <john@test> added the comment:
533 This is a followup
536 ----------
537 status: unread -> chatting
538 _________________________________________________________________________
539 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
540 http://your.tracker.url.example/issue1
541 _________________________________________________________________________
543 ''')
545     def testFollowupNoNosyRecipients(self):
546         self.doNewIssue()
547         self.instance.ADD_RECIPIENTS_TO_NOSY = 'no'
548         message = cStringIO.StringIO('''Content-Type: text/plain;
549   charset="iso-8859-1"
550 From: richard@test
551 To: issue_tracker@your.tracker.email.domain.example
552 Cc: john@test
553 Message-Id: <followup_dummy_id>
554 In-Reply-To: <dummy_test_message_id>
555 Subject: [issue1] Testing...
557 This is a followup
558 ''')
559         handler = self.instance.MailGW(self.instance, self.db)
560         handler.main(message)
562         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
563 '''FROM: roundup-admin@your.tracker.email.domain.example
564 TO: chef@bork.bork.bork
565 Content-Type: text/plain
566 Subject: [issue1] Testing...
567 To: chef@bork.bork.bork
568 From: richard <issue_tracker@your.tracker.email.domain.example>
569 Reply-To: Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
570 MIME-Version: 1.0
571 Message-Id: <followup_dummy_id>
572 In-Reply-To: <dummy_test_message_id>
573 X-Roundup-Name: Roundup issue tracker
574 Content-Transfer-Encoding: quoted-printable
577 richard <richard@test> added the comment:
579 This is a followup
582 ----------
583 status: unread -> chatting
584 _________________________________________________________________________
585 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
586 http://your.tracker.url.example/issue1
587 _________________________________________________________________________
589 ''')
591     def testNosyRemove(self):
592         self.doNewIssue()
594         message = cStringIO.StringIO('''Content-Type: text/plain;
595   charset="iso-8859-1"
596 From: richard <richard@test>
597 To: issue_tracker@your.tracker.email.domain.example
598 Message-Id: <followup_dummy_id>
599 In-Reply-To: <dummy_test_message_id>
600 Subject: [issue1] Testing... [nosy=-richard]
602 ''')
603         handler = self.instance.MailGW(self.instance, self.db)
604         handler.main(message)
605         l = self.db.issue.get('1', 'nosy')
606         l.sort()
607         self.assertEqual(l, ['2'])
609         # NO NOSY MESSAGE SHOULD BE SENT!
610         self.assert_(not os.path.exists(os.environ['SENDMAILDEBUG']))
612     def testEnc01(self):
613         self.doNewIssue()
614         message = cStringIO.StringIO('''Content-Type: text/plain;
615   charset="iso-8859-1"
616 From: mary <mary@test>
617 To: issue_tracker@your.tracker.email.domain.example
618 Message-Id: <followup_dummy_id>
619 In-Reply-To: <dummy_test_message_id>
620 Subject: [issue1] Testing...
621 Content-Type: text/plain;
622         charset="iso-8859-1"
623 Content-Transfer-Encoding: quoted-printable
625 A message with encoding (encoded oe =F6)
627 ''')
628         handler = self.instance.MailGW(self.instance, self.db)
629         handler.main(message)
630         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
631 '''FROM: roundup-admin@your.tracker.email.domain.example
632 TO: chef@bork.bork.bork, richard@test
633 Content-Type: text/plain
634 Subject: [issue1] Testing...
635 To: chef@bork.bork.bork, richard@test
636 From: mary <issue_tracker@your.tracker.email.domain.example>
637 Reply-To: Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
638 MIME-Version: 1.0
639 Message-Id: <followup_dummy_id>
640 In-Reply-To: <dummy_test_message_id>
641 X-Roundup-Name: Roundup issue tracker
642 Content-Transfer-Encoding: quoted-printable
645 mary <mary@test> added the comment:
647 A message with encoding (encoded oe =F6)
649 ----------
650 status: unread -> chatting
651 _________________________________________________________________________
652 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
653 http://your.tracker.url.example/issue1
654 _________________________________________________________________________
655 ''')
658     def testMultipartEnc01(self):
659         self.doNewIssue()
660         message = cStringIO.StringIO('''Content-Type: text/plain;
661   charset="iso-8859-1"
662 From: mary <mary@test>
663 To: issue_tracker@your.tracker.email.domain.example
664 Message-Id: <followup_dummy_id>
665 In-Reply-To: <dummy_test_message_id>
666 Subject: [issue1] Testing...
667 Content-Type: multipart/mixed;
668         boundary="----_=_NextPart_000_01"
670 This message is in MIME format. Since your mail reader does not understand
671 this format, some or all of this message may not be legible.
673 ------_=_NextPart_000_01
674 Content-Type: text/plain;
675         charset="iso-8859-1"
676 Content-Transfer-Encoding: quoted-printable
678 A message with first part encoded (encoded oe =F6)
680 ''')
681         handler = self.instance.MailGW(self.instance, self.db)
682         handler.main(message)
683         self.compareStrings(open(os.environ['SENDMAILDEBUG']).read(),
684 '''FROM: roundup-admin@your.tracker.email.domain.example
685 TO: chef@bork.bork.bork, richard@test
686 Content-Type: text/plain
687 Subject: [issue1] Testing...
688 To: chef@bork.bork.bork, richard@test
689 From: mary <issue_tracker@your.tracker.email.domain.example>
690 Reply-To: Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
691 MIME-Version: 1.0
692 Message-Id: <followup_dummy_id>
693 In-Reply-To: <dummy_test_message_id>
694 X-Roundup-Name: Roundup issue tracker
695 Content-Transfer-Encoding: quoted-printable
698 mary <mary@test> added the comment:
700 A message with first part encoded (encoded oe =F6)
702 ----------
703 status: unread -> chatting
704 _________________________________________________________________________
705 "Roundup issue tracker" <issue_tracker@your.tracker.email.domain.example>
706 http://your.tracker.url.example/issue1
707 _________________________________________________________________________
708 ''')
710 class ExtMailgwTestCase(MailgwTestCase):
711     schema = 'extended'
713 def suite():
714     l = [unittest.makeSuite(MailgwTestCase),
715          unittest.makeSuite(ExtMailgwTestCase, 'test')
716     ]
717     return unittest.TestSuite(l)
721 # $Log: not supported by cvs2svn $
722 # Revision 1.19  2002/05/23 04:26:05  richard
723 # 'I must run unit tests before committing\n' * 100
725 # Revision 1.18  2002/05/15 03:27:16  richard
726 #  . fixed SCRIPT_NAME in ZRoundup for instances not at top level of Zope
727 #    (thanks dman)
728 #  . fixed some sorting issues that were breaking some unit tests under py2.2
729 #  . mailgw test output dir was confusing the init test (but only on 2.2 *shrug*)
731 # fixed bug in the init unit test that meant only the bsddb test ran if it
732 # could (it clobbered the anydbm test)
734 # Revision 1.17  2002/05/02 07:56:34  richard
735 # . added option to automatically add the authors and recipients of messages
736 #   to the nosy lists with the options ADD_AUTHOR_TO_NOSY (default 'new') and
737 #   ADD_RECIPIENTS_TO_NOSY (default 'new'). These settings emulate the current
738 #   behaviour. Setting them to 'yes' will add the author/recipients to the nosy
739 #   on messages that create issues and followup messages.
740 # . added missing documentation for a few of the config option values
742 # Revision 1.16  2002/03/19 21:58:11  grubert
743 #  . for python2.1 test_mailgw compareString allows an extra trailing empty line (for quopri.
745 # Revision 1.15  2002/03/19 06:37:00  richard
746 # Made the email checking spit out a diff - much easier to spot the problem!
748 # Revision 1.14  2002/03/18 18:32:00  rochecompaan
749 # All messages sent to the nosy list are now encoded as quoted-printable.
751 # Revision 1.13  2002/02/15 07:08:45  richard
752 #  . Alternate email addresses are now available for users. See the MIGRATION
753 #    file for info on how to activate the feature.
755 # Revision 1.12  2002/02/15 00:13:38  richard
756 #  . #503204 ] mailgw needs a default class
757 #     - partially done - the setting of additional properties can wait for a
758 #       better configuration system.
760 # Revision 1.11  2002/02/14 23:38:12  richard
761 # Fixed the unit tests for the mailgw re: the x-roundup-name header.
762 # Also made the test runner more user-friendly:
763 #   ./run_tests            - detect all tests in test/test_<name>.py and run them
764 #   ./run_tests <name>     - run only test/test_<name>.py
765 # eg ./run_tests mailgw    - run the mailgw test from test/test_mailgw.py
767 # Revision 1.10  2002/02/12 08:08:55  grubert
768 #  . Clean up mail handling, multipart handling.
770 # Revision 1.9  2002/02/05 14:15:29  grubert
771 #  . respect encodings in non multipart messages.
773 # Revision 1.8  2002/02/04 09:40:21  grubert
774 #  . add test for multipart messages with first part being encoded.
776 # Revision 1.7  2002/01/22 11:54:45  rochecompaan
777 # Fixed status change in mail gateway.
779 # Revision 1.6  2002/01/21 10:05:48  rochecompaan
780 # Feature:
781 #  . the mail gateway now responds with an error message when invalid
782 #    values for arguments are specified for link or multilink properties
783 #  . modified unit test to check nosy and assignedto when specified as
784 #    arguments
786 # Fixed:
787 #  . fixed setting nosy as argument in subject line
789 # Revision 1.5  2002/01/15 00:12:40  richard
790 # #503340 ] creating issue with [asignedto=p.ohly]
792 # Revision 1.4  2002/01/14 07:12:15  richard
793 # removed file writing from tests...
795 # Revision 1.3  2002/01/14 02:20:15  richard
796 #  . changed all config accesses so they access either the instance or the
797 #    config attriubute on the db. This means that all config is obtained from
798 #    instance_config instead of the mish-mash of classes. This will make
799 #    switching to a ConfigParser setup easier too, I hope.
801 # At a minimum, this makes migration a _little_ easier (a lot easier in the
802 # 0.5.0 switch, I hope!)
804 # Revision 1.2  2002/01/11 23:22:29  richard
805 #  . #502437 ] rogue reactor and unittest
806 #    in short, the nosy reactor was modifying the nosy list. That code had
807 #    been there for a long time, and I suspsect it was there because we
808 #    weren't generating the nosy list correctly in other places of the code.
809 #    We're now doing that, so the nosy-modifying code can go away from the
810 #    nosy reactor.
812 # Revision 1.1  2002/01/02 02:31:38  richard
813 # Sorry for the huge checkin message - I was only intending to implement #496356
814 # but I found a number of places where things had been broken by transactions:
815 #  . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename
816 #    for _all_ roundup-generated smtp messages to be sent to.
817 #  . the transaction cache had broken the roundupdb.Class set() reactors
818 #  . newly-created author users in the mailgw weren't being committed to the db
820 # Stuff that made it into CHANGES.txt (ie. the stuff I was actually working
821 # on when I found that stuff :):
822 #  . #496356 ] Use threading in messages
823 #  . detectors were being registered multiple times
824 #  . added tests for mailgw
825 #  . much better attaching of erroneous messages in the mail gateway
830 # vim: set filetype=python ts=4 sw=4 et si