comparison test/test_mailgw.py @ 4976:b198e50dc7dc

issued2550877 fixed, the tests adapted to the more precise header comparison. Added a hint to the code how headers are handled.
author Bernhard Reiter <bernhard@intevation.de>
date Thu, 12 Mar 2015 22:11:20 +0100
parents 65a76a7f3e01
children f1a2bd1dea77
comparison
equal deleted inserted replaced
4975:2fce201a2b47 4976:b198e50dc7dc
55 def open(self, journaltag): 55 def open(self, journaltag):
56 return self.db 56 return self.db
57 57
58 class DiffHelper: 58 class DiffHelper:
59 def compareMessages(self, new, old): 59 def compareMessages(self, new, old):
60 """Compare messages for semantic equivalence.""" 60 """Compare messages for semantic equivalence.
61
62 Will raise an AssertionError with a diff for inequality.
63
64 Note that header fieldnames are case-insensitive.
65 So if a header fieldname appears more than once in different casing
66 and the values are not equal, there will be more than one entry
67 in the diff. Typical examples are "From:"/ "FROM:" and "TO:"/"To:".
68 """
61 new = email.message_from_string(new.strip()) 69 new = email.message_from_string(new.strip())
62 old = email.message_from_string(old.strip()) 70 old = email.message_from_string(old.strip())
63 71
64 # all Roundup-generated messages have "Precedence: bulk" 72 # all Roundup-generated messages have "Precedence: bulk"
65 if 'Precedence' not in old: 73 if 'Precedence' not in old:
456 464
457 This is a test submission of a new issue. 465 This is a test submission of a new issue.
458 ''') 466 ''')
459 self.compareMessages(self._get_mail(), 467 self.compareMessages(self._get_mail(),
460 '''FROM: roundup-admin@your.tracker.email.domain.example 468 '''FROM: roundup-admin@your.tracker.email.domain.example
461 TO: chef@bork.bork.bork, mary@test.test, richard@test.test 469 TO: mary@test.test, richard@test.test
462 Content-Type: text/plain; charset="utf-8" 470 Content-Type: text/plain; charset="utf-8"
463 Subject: [issue1] Testing... 471 Subject: [issue1] Testing...
464 To: mary@test.test, richard@test.test 472 To: mary@test.test, richard@test.test
465 From: "Bork, Chef" <issue_tracker@your.tracker.email.domain.example> 473 From: "Bork, Chef" <issue_tracker@your.tracker.email.domain.example>
466 Reply-To: Roundup issue tracker 474 Reply-To: Roundup issue tracker
499 507
500 This is a test submission of a new issue. 508 This is a test submission of a new issue.
501 ''') 509 ''')
502 self.compareMessages(self._get_mail(), 510 self.compareMessages(self._get_mail(),
503 '''FROM: roundup-admin@your.tracker.email.domain.example 511 '''FROM: roundup-admin@your.tracker.email.domain.example
504 TO: chef@bork.bork.bork, mary@test.test, richard@test.test 512 TO: mary@test.test, richard@test.test
505 Content-Type: text/plain; charset="utf-8" 513 Content-Type: text/plain; charset="utf-8"
506 Subject: [issue1] Testing... 514 Subject: [issue1] Testing...
507 To: mary@test.test, richard@test.test 515 To: mary@test.test, richard@test.test
508 From: "Bork, Chef" <issue_tracker@your.tracker.email.domain.example> 516 From: "Bork, Chef" <issue_tracker@your.tracker.email.domain.example>
509 Reply-To: Roundup issue tracker 517 Reply-To: Roundup issue tracker
2996 Just a test reply 3004 Just a test reply
2997 '''%locals()) 3005 '''%locals())
2998 assert os.path.exists(SENDMAILDEBUG) 3006 assert os.path.exists(SENDMAILDEBUG)
2999 self.compareMessages(self._get_mail(), 3007 self.compareMessages(self._get_mail(),
3000 '''FROM: roundup-admin@your.tracker.email.domain.example 3008 '''FROM: roundup-admin@your.tracker.email.domain.example
3001 TO: chef@bork.bork.bork, richard@test.test 3009 TO: richard@test.test
3002 Content-Type: text/plain; charset="utf-8" 3010 Content-Type: text/plain; charset="utf-8"
3003 Subject: [issue1] Testing... 3011 Subject: [issue1] Testing...
3004 To: richard@test.test 3012 To: richard@test.test
3005 From: "Bork, Chef" <issue_tracker@your.tracker.email.domain.example> 3013 From: "Bork, Chef" <issue_tracker@your.tracker.email.domain.example>
3006 Reply-To: Roundup issue tracker 3014 Reply-To: Roundup issue tracker

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