Skip to content

Commit f385ea7

Browse files
committed
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
1 parent 4bfaf89 commit f385ea7

File tree

1 file changed

+67
-2
lines changed

1 file changed

+67
-2
lines changed

test/test_mailgw.py

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,6 +3333,30 @@ def testEmailQuotingNewIsFollowup(self):
33333333
self.assertEqual(content, '''This is a followup''')
33343334
self.assertEqual(summary, '''This is a followup''')
33353335

3336+
def testEmailBodyUnchangedNewIsNew(self):
3337+
mysig = "\n--\nmy sig\n\n"
3338+
self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'new'
3339+
# create the message, remove the prefix from subject
3340+
testmessage=self.firstquotingtest.replace(" Re: [issue1]", "") + mysig
3341+
nodeid = self._handle_mail(testmessage)
3342+
3343+
msgs = self.db.issue.get(nodeid, 'messages')
3344+
# validate content and summary
3345+
content = self.db.msg.get(msgs[0], 'content')
3346+
self.assertEqual(content, '''Blah blah wrote:
3347+
> Blah bklaskdfj sdf asdf jlaskdf skj sdkfjl asdf
3348+
> skdjlkjsdfalsdkfjasdlfkj dlfksdfalksd fj
3349+
>
3350+
3351+
This is a followup\n''' + mysig[:-2])
3352+
# the :-2 requrement to strip the trailing newlines is probably a bug
3353+
# somewhere mailgw has right content maybe trailing \n are stripped by
3354+
# msg or something.
3355+
3356+
summary = self.db.msg.get(msgs[0], 'summary')
3357+
self.assertEqual(summary, '''This is a followup''')
3358+
3359+
33363360
fourthquotingtest = '''Content-Type: text/plain;
33373361
charset="iso-8859-1"
33383362
From: richard <[email protected]>
@@ -3396,7 +3420,7 @@ def testEmailBodyUnchangedNewIsNo(self):
33963420
self.assertEqual(summary, '''This is a followup''')
33973421

33983422
def testEmailBodyUnchangedNewIsYes(self):
3399-
mysig = "--\nmy sig\n\n"
3423+
mysig = "\n--\nmy sig\n\n"
34003424
self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'yes'
34013425
# create the message, remove the prefix from subject
34023426
testmessage=self.firstquotingtest.replace(" Re: [issue1]", "") + mysig
@@ -3418,8 +3442,49 @@ def testEmailBodyUnchangedNewIsYes(self):
34183442
summary = self.db.msg.get(msgs[0], 'summary')
34193443
self.assertEqual(summary, '''This is a followup''')
34203444

3445+
def testEmailBodyUnchangedFollowupIsNew(self):
3446+
mysig = "\n--\nmy sig\n\n"
3447+
self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'new'
3448+
3449+
# create issue1 that we can followup on
3450+
self.doNewIssue()
3451+
testmessage=self.firstquotingtest + mysig
3452+
nodeid = self._handle_mail(testmessage)
3453+
msgs = self.db.issue.get(nodeid, 'messages')
3454+
# validate content and summary
3455+
content = self.db.msg.get(msgs[1], 'content')
3456+
self.assertEqual(content, '''Blah blah wrote:
3457+
> Blah bklaskdfj sdf asdf jlaskdf skj sdkfjl asdf
3458+
> skdjlkjsdfalsdkfjasdlfkj dlfksdfalksd fj
3459+
>
3460+
3461+
This is a followup''')
3462+
3463+
summary = self.db.msg.get(msgs[1], 'summary')
3464+
self.assertEqual(summary, '''This is a followup''')
3465+
3466+
def testEmailBodyUnchangedFollowupIsNo(self):
3467+
mysig = "\n--\nmy sig\n\n"
3468+
self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'No'
3469+
# create the message, remove the prefix from subject
3470+
self.doNewIssue()
3471+
testmessage=self.firstquotingtest + mysig
3472+
nodeid = self._handle_mail(testmessage)
3473+
3474+
msgs = self.db.issue.get(nodeid, 'messages')
3475+
# validate content and summary
3476+
content = self.db.msg.get(msgs[1], 'content')
3477+
self.assertEqual(content, '''Blah blah wrote:
3478+
> Blah bklaskdfj sdf asdf jlaskdf skj sdkfjl asdf
3479+
> skdjlkjsdfalsdkfjasdlfkj dlfksdfalksd fj
3480+
>
3481+
3482+
This is a followup''')
3483+
summary = self.db.msg.get(msgs[1], 'summary')
3484+
self.assertEqual(summary, '''This is a followup''')
3485+
34213486
def testEmailBodyUnchangedFollowupIsYes(self):
3422-
mysig = "--\nmy sig\n\n"
3487+
mysig = "\n--\nmy sig\n\n"
34233488
self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'yes'
34243489

34253490
# create issue1 that we can followup on

0 commit comments

Comments
 (0)