Mercurial > p > roundup > code
diff test/test_mailgw.py @ 5117:14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
The mailgw config options: keep_quoted_text and leave_body_unchanged
can now have a new values: new. If set to new, keep_quoted_text acts
like yes if the message is starting a new issue. Otherise it strips
quoted text.
This allows somebody to start a new issue by forwarding
a threaded email (with multiple quoted parts) into roundup and
keeping all the quoted parts. If leave_body_unchanged is set to
new, even the signature on the email that starts a new issue will be
preserved.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 02 Jul 2016 20:05:06 -0400 |
| parents | 43a1f7fe39f5 |
| children | 226052e0cc4c |
line wrap: on
line diff
--- a/test/test_mailgw.py Sat Jul 02 17:55:23 2016 -0400 +++ b/test/test_mailgw.py Sat Jul 02 20:05:06 2016 -0400 @@ -2547,6 +2547,75 @@ self.innerTestQuoting(self.firstquotingtest, '''This is a followup ''', 'This is a followup') + def testEmailQuotingNewIsNew(self): + self.instance.config.EMAIL_KEEP_QUOTED_TEXT = 'new' + # create the message, remove the prefix from subject + testmessage=self.firstquotingtest.replace(" Re: [issue1]", "") + nodeid = self._handle_mail(testmessage) + + msgs = self.db.issue.get(nodeid, 'messages') + # validate content and summary + content = self.db.msg.get(msgs[0], 'content') + self.assertEqual(content, '''Blah blah wrote: +> Blah bklaskdfj sdf asdf jlaskdf skj sdkfjl asdf +> skdjlkjsdfalsdkfjasdlfkj dlfksdfalksd fj +> + +This is a followup''') + + summary = self.db.msg.get(msgs[0], 'summary') + self.assertEqual(summary, '''This is a followup''') + + def testEmailQuotingNewIsFollowup(self): + self.instance.config.EMAIL_KEEP_QUOTED_TEXT = 'new' + # create issue1 that we can followup on + self.doNewIssue() + # add the second message to the issue + nodeid = self._handle_mail(self.firstquotingtest) + msgs = self.db.issue.get(nodeid, 'messages') + # check second message for accuracy + content = self.db.msg.get(msgs[1], 'content') + summary = self.db.msg.get(msgs[1], 'summary') + self.assertEqual(content, '''This is a followup''') + self.assertEqual(summary, '''This is a followup''') + + def testEmailReplaceBodyNewIsNew(self): + mysig = "--\nmy sig\n\n" + self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'new' + # create the message, remove the prefix from subject + testmessage=self.firstquotingtest.replace(" Re: [issue1]", "") + mysig + nodeid = self._handle_mail(testmessage) + + msgs = self.db.issue.get(nodeid, 'messages') + # validate content and summary + content = self.db.msg.get(msgs[0], 'content') + self.assertEqual(content, '''Blah blah wrote: +> Blah bklaskdfj sdf asdf jlaskdf skj sdkfjl asdf +> skdjlkjsdfalsdkfjasdlfkj dlfksdfalksd fj +> + +This is a followup\n''' + mysig[:-2]) + # the :-2 requrement to strip the trailing newlines is probably a bug + # somewhere mailgw has right content maybe trailing \n are stripped by + # msg or something. + + summary = self.db.msg.get(msgs[0], 'summary') + self.assertEqual(summary, '''This is a followup''') + + def testEmailReplaceBodyNewIsFollowup(self): + mysig = "\n--\nmy sig\n" + self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'new' + # create issue1 that we can followup on + self.doNewIssue() + # add the second message to the issue + nodeid = self._handle_mail(self.firstquotingtest + mysig) + msgs = self.db.issue.get(nodeid, 'messages') + # check second message for accuracy + content = self.db.msg.get(msgs[1], 'content') + summary = self.db.msg.get(msgs[1], 'summary') + self.assertEqual(content, '''Blah blah wrote:\n> Blah bklaskdfj sdf asdf jlaskdf skj sdkfjl asdf\n> skdjlkjsdfalsdkfjasdlfkj dlfksdfalksd fj\n>\n\nThis is a followup''') + self.assertEqual(summary, '''This is a followup''') + def testEmailQuotingRemove(self): self.instance.config.EMAIL_KEEP_QUOTED_TEXT = 'yes' self.innerTestQuoting(self.firstquotingtest, '''Blah blah wrote:
