Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 5312:a4fe76fba54a
issue2550957: Duplicate emails (with patch).
Bcc and cc users passed to nosymessage are not properly recorded.
This results in duplicate emails. Patch by Trent Gamblin (trentgg).
Applied by and test added by John Rouillard.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 07 Nov 2017 20:58:48 -0500 |
| parents | e20f472fde7d |
| children | 35ea9b1efc14 |
comparison
equal
deleted
inserted
replaced
| 5311:1303ba0b5358 | 5312:a4fe76fba54a |
|---|---|
| 1704 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> | 1704 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> |
| 1705 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue2> | 1705 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue2> |
| 1706 _______________________________________________________________________ | 1706 _______________________________________________________________________ |
| 1707 ''') | 1707 ''') |
| 1708 | 1708 |
| 1709 def testNosyMessageCcBccEtc(self): | |
| 1710 self.doNewIssue() | |
| 1711 oldvalues = self.db.getnode('issue', '1').copy() | |
| 1712 oldvalues['assignedto'] = None | |
| 1713 # reconstruct old behaviour: This would reuse the | |
| 1714 # database-handle from the doNewIssue above which has committed | |
| 1715 # as user "Chef". So we close and reopen the db as that user. | |
| 1716 #self.db.close() actually don't close 'cos this empties memorydb | |
| 1717 self.db = self.instance.open('Chef') | |
| 1718 self.db.issue.set('1', assignedto=self.chef_id) | |
| 1719 self.db.commit() | |
| 1720 # note user 3 is both in cc and bcc. The one in cc takes | |
| 1721 # precedence and stops the bcc copy from being sent to user 3.. | |
| 1722 # new email is generated for bcc peoples: admin and kermit | |
| 1723 # get it. | |
| 1724 self.db.issue.nosymessage('1', None, oldvalues, | |
| 1725 cc=['3','4', '5'], bcc=['1', '3', '5'], | |
| 1726 cc_emails=['john@example.com'], | |
| 1727 bcc_emails=["kermit@example.com"]) | |
| 1728 new_mail = "" | |
| 1729 for line in self._get_mail().split("\n"): | |
| 1730 if "Message-Id: " in line: | |
| 1731 continue | |
| 1732 if "Date: " in line: | |
| 1733 continue | |
| 1734 new_mail += line+"\n" | |
| 1735 | |
| 1736 # new_mail is a mbox style string with 2 emails. | |
| 1737 # we need to split the emails and compare. | |
| 1738 new_mails=new_mail.split("\nFrom ") | |
| 1739 # restore the "From " prefix removed from first line of | |
| 1740 # second message by strip. | |
| 1741 new_mails[1]="From " + new_mail.split("\nFrom ")[1] | |
| 1742 | |
| 1743 self.compareMessages(new_mails[0], """ | |
| 1744 FROM: roundup-admin@your.tracker.email.domain.example | |
| 1745 TO: chef@bork.bork.bork, fred@example.com, john@example.com, richard@test.test | |
| 1746 Content-Type: text/plain; charset="utf-8" | |
| 1747 Subject: [issue1] Testing... | |
| 1748 To: chef@bork.bork.bork, fred@example.com, john@example.com, richard@test.test | |
| 1749 From: "Bork, Chef" <issue_tracker@your.tracker.email.domain.example> | |
| 1750 X-Roundup-Name: Roundup issue tracker | |
| 1751 X-Roundup-Loop: hello | |
| 1752 X-Roundup-Issue-Status: unread | |
| 1753 X-Roundup-Version: 1.3.3 | |
| 1754 In-Reply-To: <dummy_test_message_id> | |
| 1755 MIME-Version: 1.0 | |
| 1756 Reply-To: Roundup issue tracker | |
| 1757 <issue_tracker@your.tracker.email.domain.example> | |
| 1758 Content-Transfer-Encoding: quoted-printable | |
| 1759 | |
| 1760 | |
| 1761 Change by Bork, Chef <chef@bork.bork.bork>: | |
| 1762 | |
| 1763 | |
| 1764 ---------- | |
| 1765 assignedto: -> Chef | |
| 1766 | |
| 1767 _______________________________________________________________________ | |
| 1768 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> | |
| 1769 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | |
| 1770 _______________________________________________________________________ | |
| 1771 """) | |
| 1772 | |
| 1773 self.compareMessages(new_mails[1], """ | |
| 1774 FROM: roundup-admin@your.tracker.email.domain.example | |
| 1775 TO: admin@test.com, kermit@example.com | |
| 1776 Content-Type: text/plain; charset="utf-8" | |
| 1777 Subject: [issue1] Testing... | |
| 1778 To: chef@bork.bork.bork, fred@example.com, john@example.com, richard@test.test | |
| 1779 From: "Bork, Chef" <issue_tracker@your.tracker.email.domain.example> | |
| 1780 X-Roundup-Name: Roundup issue tracker | |
| 1781 X-Roundup-Loop: hello | |
| 1782 X-Roundup-Issue-Status: unread | |
| 1783 X-Roundup-Version: 1.3.3 | |
| 1784 In-Reply-To: <dummy_test_message_id> | |
| 1785 MIME-Version: 1.0 | |
| 1786 Reply-To: Roundup issue tracker | |
| 1787 <issue_tracker@your.tracker.email.domain.example> | |
| 1788 Content-Transfer-Encoding: quoted-printable | |
| 1789 | |
| 1790 | |
| 1791 Change by Bork, Chef <chef@bork.bork.bork>: | |
| 1792 | |
| 1793 | |
| 1794 ---------- | |
| 1795 assignedto: -> Chef | |
| 1796 | |
| 1797 _______________________________________________________________________ | |
| 1798 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> | |
| 1799 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> | |
| 1800 _______________________________________________________________________ | |
| 1801 """) | |
| 1802 | |
| 1803 | |
| 1709 def testPropertyChangeOnly(self): | 1804 def testPropertyChangeOnly(self): |
| 1710 self.doNewIssue() | 1805 self.doNewIssue() |
| 1711 oldvalues = self.db.getnode('issue', '1').copy() | 1806 oldvalues = self.db.getnode('issue', '1').copy() |
| 1712 oldvalues['assignedto'] = None | 1807 oldvalues['assignedto'] = None |
| 1713 # reconstruct old behaviour: This would reuse the | 1808 # reconstruct old behaviour: This would reuse the |
