comparison test/test_mailgw.py @ 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 cde2b45d599a
children c12377fb4144
comparison
equal deleted inserted replaced
7564:49ae502a41b1 7565:0713c286f71c
3331 content = self.db.msg.get(msgs[1], 'content') 3331 content = self.db.msg.get(msgs[1], 'content')
3332 summary = self.db.msg.get(msgs[1], 'summary') 3332 summary = self.db.msg.get(msgs[1], 'summary')
3333 self.assertEqual(content, '''This is a followup''') 3333 self.assertEqual(content, '''This is a followup''')
3334 self.assertEqual(summary, '''This is a followup''') 3334 self.assertEqual(summary, '''This is a followup''')
3335 3335
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
3336 fourthquotingtest = '''Content-Type: text/plain; 3360 fourthquotingtest = '''Content-Type: text/plain;
3337 charset="iso-8859-1" 3361 charset="iso-8859-1"
3338 From: richard <richard@test.test> 3362 From: richard <richard@test.test>
3339 To: issue_tracker@your.tracker.email.domain.example 3363 To: issue_tracker@your.tracker.email.domain.example
3340 Message-Id: <followup_dummy_id> 3364 Message-Id: <followup_dummy_id>
3394 3418
3395 summary = self.db.msg.get(msgs[0], 'summary') 3419 summary = self.db.msg.get(msgs[0], 'summary')
3396 self.assertEqual(summary, '''This is a followup''') 3420 self.assertEqual(summary, '''This is a followup''')
3397 3421
3398 def testEmailBodyUnchangedNewIsYes(self): 3422 def testEmailBodyUnchangedNewIsYes(self):
3399 mysig = "--\nmy sig\n\n" 3423 mysig = "\n--\nmy sig\n\n"
3400 self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'yes' 3424 self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'yes'
3401 # create the message, remove the prefix from subject 3425 # create the message, remove the prefix from subject
3402 testmessage=self.firstquotingtest.replace(" Re: [issue1]", "") + mysig 3426 testmessage=self.firstquotingtest.replace(" Re: [issue1]", "") + mysig
3403 nodeid = self._handle_mail(testmessage) 3427 nodeid = self._handle_mail(testmessage)
3404 3428
3416 # msg or something. 3440 # msg or something.
3417 3441
3418 summary = self.db.msg.get(msgs[0], 'summary') 3442 summary = self.db.msg.get(msgs[0], 'summary')
3419 self.assertEqual(summary, '''This is a followup''') 3443 self.assertEqual(summary, '''This is a followup''')
3420 3444
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
3421 def testEmailBodyUnchangedFollowupIsYes(self): 3486 def testEmailBodyUnchangedFollowupIsYes(self):
3422 mysig = "--\nmy sig\n\n" 3487 mysig = "\n--\nmy sig\n\n"
3423 self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'yes' 3488 self.instance.config.EMAIL_LEAVE_BODY_UNCHANGED = 'yes'
3424 3489
3425 # create issue1 that we can followup on 3490 # create issue1 that we can followup on
3426 self.doNewIssue() 3491 self.doNewIssue()
3427 testmessage=self.firstquotingtest + mysig 3492 testmessage=self.firstquotingtest + mysig

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