comparison test/test_mailgw.py @ 5675:f3d68c1bb96e

issue2551018 add new nosy_filter parameter to nosymessage. Function passed as nosy_filter can rewrite the nosy message body before it's sent. Tom Ekberg tekberg did the work.
author John Rouillard <rouilj@ieee.org>
date Mon, 25 Mar 2019 19:45:08 -0400
parents f8893e1cde0d
children 2c0f89edabe1
comparison
equal deleted inserted replaced
5674:6dc4dba1c225 5675:f3d68c1bb96e
1857 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> 1857 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
1858 _______________________________________________________________________ 1858 _______________________________________________________________________
1859 """) 1859 """)
1860 1860
1861 1861
1862 def testNosyMessageNoteFilter(self):
1863 def note_filter(original_note, issue_id, db, newvalues, oldvalues):
1864 return 'This content came from note_filter().'
1865 self.doNewIssue()
1866 oldvalues = self.db.getnode('issue', '1').copy()
1867 oldvalues['assignedto'] = None
1868 # reconstruct old behaviour: This would reuse the
1869 # database-handle from the doNewIssue above which has committed
1870 # as user "Chef". So we close and reopen the db as that user.
1871 #self.db.close() actually don't close 'cos this empties memorydb
1872 self.db = self.instance.open('Chef')
1873 self.db.issue.set('1', assignedto=self.chef_id)
1874 self.db.commit()
1875 self.db.issue.nosymessage('1', None, oldvalues,
1876 cc=['3','4', '5'],
1877 cc_emails=['john@example.com'],
1878 note_filter=note_filter)
1879 new_mail = ""
1880 # Message-Id: and Date: change every time - remove them.
1881 for line in self._get_mail().split("\n"):
1882 if "Message-Id: " in line:
1883 continue
1884 if "Date: " in line:
1885 continue
1886 new_mail += line+"\n"
1887
1888 self.compareMessages(new_mail, """
1889 FROM: roundup-admin@your.tracker.email.domain.example
1890 TO: chef@bork.bork.bork, fred@example.com, john@example.com, richard@test.test
1891 Content-Type: text/plain; charset="utf-8"
1892 Subject: [issue1] Testing...
1893 To: chef@bork.bork.bork, fred@example.com, john@example.com, richard@test.test
1894 From: "Bork, Chef" <issue_tracker@your.tracker.email.domain.example>
1895 X-Roundup-Name: Roundup issue tracker
1896 X-Roundup-Loop: hello
1897 X-Roundup-Issue-Status: unread
1898 X-Roundup-Version: 1.3.3
1899 In-Reply-To: <dummy_test_message_id>
1900 MIME-Version: 1.0
1901 Reply-To: Roundup issue tracker
1902 <issue_tracker@your.tracker.email.domain.example>
1903 Content-Transfer-Encoding: quoted-printable
1904
1905
1906 Change by Bork, Chef <chef@bork.bork.bork>:
1907
1908 This content came from note_filter().
1909
1910 _______________________________________________________________________
1911 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
1912 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
1913 _______________________________________________________________________
1914 """)
1915
1916
1862 def testPropertyChangeOnly(self): 1917 def testPropertyChangeOnly(self):
1863 self.doNewIssue() 1918 self.doNewIssue()
1864 oldvalues = self.db.getnode('issue', '1').copy() 1919 oldvalues = self.db.getnode('issue', '1').copy()
1865 oldvalues['assignedto'] = None 1920 oldvalues['assignedto'] = None
1866 # reconstruct old behaviour: This would reuse the 1921 # reconstruct old behaviour: This would reuse the

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