Mercurial > p > roundup > code
changeset 7565:0713c286f71c
Fix tests
The testEmailBodyUnchangedNewIsYes was using a signature (sig) that
didn't have a blank line before it. Therefore the sig wasn't
recognised as a message section and wasn't a candidate to be removed
even if EMAIL_LEAVE_BODY_UNCHANGED was set to no.
Appended a newline before the signature block so testing with
self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'no'
will cause test to fail and setting it to yes (the test condition)
will cause test to pass by keeping signature.
Make same sig change to testEmailBodyUnchangedFollowupIsYes for same
reason. Add new tests for other permutations:
testEmailBodyUnchangedNewIsNew - keep sig
testEmailBodyUnchangedFollowupIsNew - remove sig
testEmailBodyUnchangedFollowupIsNo - remove sig
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 23 Jul 2023 22:04:27 -0400 |
| parents | 49ae502a41b1 |
| children | df87f02c2930 |
| files | test/test_mailgw.py |
| diffstat | 1 files changed, 67 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/test/test_mailgw.py Sun Jul 23 20:54:16 2023 -0400 +++ b/test/test_mailgw.py Sun Jul 23 22:04:27 2023 -0400 @@ -3333,6 +3333,30 @@ self.assertEqual(content, '''This is a followup''') self.assertEqual(summary, '''This is a followup''') + def testEmailBodyUnchangedNewIsNew(self): + mysig = "\n--\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''') + + fourthquotingtest = '''Content-Type: text/plain; charset="iso-8859-1" From: richard <richard@test.test> @@ -3396,7 +3420,7 @@ self.assertEqual(summary, '''This is a followup''') def testEmailBodyUnchangedNewIsYes(self): - mysig = "--\nmy sig\n\n" + mysig = "\n--\nmy sig\n\n" self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'yes' # create the message, remove the prefix from subject testmessage=self.firstquotingtest.replace(" Re: [issue1]", "") + mysig @@ -3418,8 +3442,49 @@ summary = self.db.msg.get(msgs[0], 'summary') self.assertEqual(summary, '''This is a followup''') + def testEmailBodyUnchangedFollowupIsNew(self): + mysig = "\n--\nmy sig\n\n" + self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'new' + + # create issue1 that we can followup on + self.doNewIssue() + testmessage=self.firstquotingtest + mysig + nodeid = self._handle_mail(testmessage) + msgs = self.db.issue.get(nodeid, 'messages') + # validate content and summary + content = self.db.msg.get(msgs[1], '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[1], 'summary') + self.assertEqual(summary, '''This is a followup''') + + def testEmailBodyUnchangedFollowupIsNo(self): + mysig = "\n--\nmy sig\n\n" + self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'No' + # create the message, remove the prefix from subject + self.doNewIssue() + testmessage=self.firstquotingtest + mysig + nodeid = self._handle_mail(testmessage) + + msgs = self.db.issue.get(nodeid, 'messages') + # validate content and summary + content = self.db.msg.get(msgs[1], '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[1], 'summary') + self.assertEqual(summary, '''This is a followup''') + def testEmailBodyUnchangedFollowupIsYes(self): - mysig = "--\nmy sig\n\n" + mysig = "\n--\nmy sig\n\n" self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'yes' # create issue1 that we can followup on
