Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 5116:0902c046cdd8 | 5117:14abd0a67207 |
|---|---|
| 2544 | 2544 |
| 2545 def testEmailQuoting(self): | 2545 def testEmailQuoting(self): |
| 2546 self.instance.config.EMAIL_KEEP_QUOTED_TEXT = 'no' | 2546 self.instance.config.EMAIL_KEEP_QUOTED_TEXT = 'no' |
| 2547 self.innerTestQuoting(self.firstquotingtest, '''This is a followup | 2547 self.innerTestQuoting(self.firstquotingtest, '''This is a followup |
| 2548 ''', 'This is a followup') | 2548 ''', 'This is a followup') |
| 2549 | |
| 2550 def testEmailQuotingNewIsNew(self): | |
| 2551 self.instance.config.EMAIL_KEEP_QUOTED_TEXT = 'new' | |
| 2552 # create the message, remove the prefix from subject | |
| 2553 testmessage=self.firstquotingtest.replace(" Re: [issue1]", "") | |
| 2554 nodeid = self._handle_mail(testmessage) | |
| 2555 | |
| 2556 msgs = self.db.issue.get(nodeid, 'messages') | |
| 2557 # validate content and summary | |
| 2558 content = self.db.msg.get(msgs[0], 'content') | |
| 2559 self.assertEqual(content, '''Blah blah wrote: | |
| 2560 > Blah bklaskdfj sdf asdf jlaskdf skj sdkfjl asdf | |
| 2561 > skdjlkjsdfalsdkfjasdlfkj dlfksdfalksd fj | |
| 2562 > | |
| 2563 | |
| 2564 This is a followup''') | |
| 2565 | |
| 2566 summary = self.db.msg.get(msgs[0], 'summary') | |
| 2567 self.assertEqual(summary, '''This is a followup''') | |
| 2568 | |
| 2569 def testEmailQuotingNewIsFollowup(self): | |
| 2570 self.instance.config.EMAIL_KEEP_QUOTED_TEXT = 'new' | |
| 2571 # create issue1 that we can followup on | |
| 2572 self.doNewIssue() | |
| 2573 # add the second message to the issue | |
| 2574 nodeid = self._handle_mail(self.firstquotingtest) | |
| 2575 msgs = self.db.issue.get(nodeid, 'messages') | |
| 2576 # check second message for accuracy | |
| 2577 content = self.db.msg.get(msgs[1], 'content') | |
| 2578 summary = self.db.msg.get(msgs[1], 'summary') | |
| 2579 self.assertEqual(content, '''This is a followup''') | |
| 2580 self.assertEqual(summary, '''This is a followup''') | |
| 2581 | |
| 2582 def testEmailReplaceBodyNewIsNew(self): | |
| 2583 mysig = "--\nmy sig\n\n" | |
| 2584 self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'new' | |
| 2585 # create the message, remove the prefix from subject | |
| 2586 testmessage=self.firstquotingtest.replace(" Re: [issue1]", "") + mysig | |
| 2587 nodeid = self._handle_mail(testmessage) | |
| 2588 | |
| 2589 msgs = self.db.issue.get(nodeid, 'messages') | |
| 2590 # validate content and summary | |
| 2591 content = self.db.msg.get(msgs[0], 'content') | |
| 2592 self.assertEqual(content, '''Blah blah wrote: | |
| 2593 > Blah bklaskdfj sdf asdf jlaskdf skj sdkfjl asdf | |
| 2594 > skdjlkjsdfalsdkfjasdlfkj dlfksdfalksd fj | |
| 2595 > | |
| 2596 | |
| 2597 This is a followup\n''' + mysig[:-2]) | |
| 2598 # the :-2 requrement to strip the trailing newlines is probably a bug | |
| 2599 # somewhere mailgw has right content maybe trailing \n are stripped by | |
| 2600 # msg or something. | |
| 2601 | |
| 2602 summary = self.db.msg.get(msgs[0], 'summary') | |
| 2603 self.assertEqual(summary, '''This is a followup''') | |
| 2604 | |
| 2605 def testEmailReplaceBodyNewIsFollowup(self): | |
| 2606 mysig = "\n--\nmy sig\n" | |
| 2607 self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'new' | |
| 2608 # create issue1 that we can followup on | |
| 2609 self.doNewIssue() | |
| 2610 # add the second message to the issue | |
| 2611 nodeid = self._handle_mail(self.firstquotingtest + mysig) | |
| 2612 msgs = self.db.issue.get(nodeid, 'messages') | |
| 2613 # check second message for accuracy | |
| 2614 content = self.db.msg.get(msgs[1], 'content') | |
| 2615 summary = self.db.msg.get(msgs[1], 'summary') | |
| 2616 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''') | |
| 2617 self.assertEqual(summary, '''This is a followup''') | |
| 2549 | 2618 |
| 2550 def testEmailQuotingRemove(self): | 2619 def testEmailQuotingRemove(self): |
| 2551 self.instance.config.EMAIL_KEEP_QUOTED_TEXT = 'yes' | 2620 self.instance.config.EMAIL_KEEP_QUOTED_TEXT = 'yes' |
| 2552 self.innerTestQuoting(self.firstquotingtest, '''Blah blah wrote: | 2621 self.innerTestQuoting(self.firstquotingtest, '''Blah blah wrote: |
| 2553 > Blah bklaskdfj sdf asdf jlaskdf skj sdkfjl asdf | 2622 > Blah bklaskdfj sdf asdf jlaskdf skj sdkfjl asdf |
