Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 4498:8df9492c2746
Fix file-unlink bug in mailgw
(Ralfs oversight when refactoring the mail gateway code) -- if a
message is sent that contains no attachments, all previous files of
the issue are unlinked, thanks to Rafal Bisingier for reporting and
proposing a fix.
I've now added a regression test that catches this issue.
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Sun, 29 May 2011 18:25:49 +0000 |
| parents | 0bdcb1e7f7ce |
| children | 9f488541802f |
comparison
equal
deleted
inserted
replaced
| 4497:29576edb45d5 | 4498:8df9492c2746 |
|---|---|
| 623 self.assertEqual(f.name, names.get (n, 'unnamed')) | 623 self.assertEqual(f.name, names.get (n, 'unnamed')) |
| 624 if n in content : | 624 if n in content : |
| 625 self.assertEqual(f.content, content [n]) | 625 self.assertEqual(f.content, content [n]) |
| 626 self.assertEqual(msg.content, 'test attachment second text/plain') | 626 self.assertEqual(msg.content, 'test attachment second text/plain') |
| 627 | 627 |
| 628 def testMultipartKeepFiles(self): | |
| 629 self.doNewIssue() | |
| 630 self._handle_mail(self.multipart_msg) | |
| 631 messages = self.db.issue.get('1', 'messages') | |
| 632 messages.sort() | |
| 633 msg = self.db.msg.getnode (messages[-1]) | |
| 634 assert(len(msg.files) == 5) | |
| 635 issue = self.db.issue.getnode ('1') | |
| 636 assert(len(issue.files) == 5) | |
| 637 names = {0 : 'first.dvi', 4 : 'second.dvi'} | |
| 638 content = {3 : 'test attachment third text/plain\n', | |
| 639 4 : 'Just a test\n'} | |
| 640 for n, id in enumerate (msg.files): | |
| 641 f = self.db.file.getnode (id) | |
| 642 self.assertEqual(f.name, names.get (n, 'unnamed')) | |
| 643 if n in content : | |
| 644 self.assertEqual(f.content, content [n]) | |
| 645 self.assertEqual(msg.content, 'test attachment second text/plain') | |
| 646 self._handle_mail('''From: mary <mary@test.test> | |
| 647 To: issue_tracker@your.tracker.email.domain.example | |
| 648 Message-Id: <followup_dummy_id2> | |
| 649 In-Reply-To: <dummy_test_message_id> | |
| 650 Subject: [issue1] Testing... | |
| 651 | |
| 652 This ist a message without attachment | |
| 653 ''') | |
| 654 issue = self.db.issue.getnode ('1') | |
| 655 assert(len(issue.files) == 5) | |
| 656 self.assertEqual(issue.files, ['1', '2', '3', '4', '5']) | |
| 657 | |
| 628 def testMultipartDropAlternatives(self): | 658 def testMultipartDropAlternatives(self): |
| 629 self.doNewIssue() | 659 self.doNewIssue() |
| 630 self.db.config.MAILGW_IGNORE_ALTERNATIVES = True | 660 self.db.config.MAILGW_IGNORE_ALTERNATIVES = True |
| 631 self._handle_mail(self.multipart_msg) | 661 self._handle_mail(self.multipart_msg) |
| 632 messages = self.db.issue.get('1', 'messages') | 662 messages = self.db.issue.get('1', 'messages') |
