comparison test/test_mailgw.py @ 4974:65a76a7f3e01

issue2550877 partly fixed. * Added docstring hint to _get_mail(). * Fixed FROM: lines in testMultipartRFC822() and testUnknownUser()
author Bernhard Reiter <bernhard@intevation.de>
date Wed, 11 Mar 2015 21:47:41 +0100
parents e2793024bd44
children b198e50dc7dc
comparison
equal deleted inserted replaced
4973:9d10838bfdb4 4974:65a76a7f3e01
196 handler = self._create_mailgw(message, args) 196 handler = self._create_mailgw(message, args)
197 handler.trapExceptions = trap_exc 197 handler.trapExceptions = trap_exc
198 return handler.main(StringIO(message)) 198 return handler.main(StringIO(message))
199 199
200 def _get_mail(self): 200 def _get_mail(self):
201 """Reads an email that has been written to file via debug output.
202
203 Note: the resulting email will have three leading extra lines
204 written by the self.debug code branch in Mailer.smtp_send().
205 """
201 f = open(SENDMAILDEBUG) 206 f = open(SENDMAILDEBUG)
202 try: 207 try:
203 return f.read() 208 return f.read()
204 finally: 209 finally:
205 f.close() 210 f.close()
999 for n, id in enumerate (msg.files): 1004 for n, id in enumerate (msg.files):
1000 f = self.db.file.getnode (id) 1005 f = self.db.file.getnode (id)
1001 self.assertEqual(f.name, name) 1006 self.assertEqual(f.name, name)
1002 self.assertEqual(msg.content, 'First part: Text') 1007 self.assertEqual(msg.content, 'First part: Text')
1003 self.compareMessages(self._get_mail(), 1008 self.compareMessages(self._get_mail(),
1004 '''TO: chef@bork.bork.bork, richard@test.test 1009 '''FROM: roundup-admin@your.tracker.email.domain.example
1010 TO: chef@bork.bork.bork, richard@test.test
1005 Content-Type: text/plain; charset="utf-8" 1011 Content-Type: text/plain; charset="utf-8"
1006 Subject: [issue1] Testing... 1012 Subject: [issue1] Testing...
1007 To: chef@bork.bork.bork, richard@test.test 1013 To: chef@bork.bork.bork, richard@test.test
1008 From: "Contrary, Mary" <issue_tracker@your.tracker.email.domain.example> 1014 From: "Contrary, Mary" <issue_tracker@your.tracker.email.domain.example>
1009 Reply-To: Roundup issue tracker 1015 Reply-To: Roundup issue tracker
2038 This is a test submission of a new issue. 2044 This is a test submission of a new issue.
2039 ''' 2045 '''
2040 # trap_exc=1: we want a bounce message: 2046 # trap_exc=1: we want a bounce message:
2041 ret = self._handle_mail(message, trap_exc=1) 2047 ret = self._handle_mail(message, trap_exc=1)
2042 self.compareMessages(self._get_mail(), 2048 self.compareMessages(self._get_mail(),
2043 '''FROM: Roundup issue tracker <roundup-admin@your.tracker.email.domain.example> 2049 '''FROM: roundup-admin@your.tracker.email.domain.example
2044 TO: nonexisting@bork.bork.bork 2050 TO: nonexisting@bork.bork.bork
2045 From nobody Tue Jul 14 12:04:11 2009 2051 From nobody Tue Jul 14 12:04:11 2009
2046 Content-Type: multipart/mixed; boundary="===============0639262320==" 2052 Content-Type: multipart/mixed; boundary="===============0639262320=="
2047 MIME-Version: 1.0 2053 MIME-Version: 1.0
2048 Subject: Failed issue tracker submission 2054 Subject: Failed issue tracker submission

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