comparison test/test_mailgw.py @ 5829:7c05c481e470

Add test for standard_message .. with utf-8 subject, TO header, and content.
author Ralf Schlatterbeck <rsc@runtux.com>
date Wed, 03 Jul 2019 09:03:02 +0200
parents 95a366d46065
children 75586a0c26c0
comparison
equal deleted inserted replaced
5828:bd245858c823 5829:7c05c481e470
1617 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> 1617 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
1618 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> 1618 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
1619 _______________________________________________________________________ 1619 _______________________________________________________________________
1620 ''') 1620 ''')
1621 1621
1622 def testFollowupUTF8(self):
1623 self.doNewIssue()
1624
1625 self._handle_mail('''Content-Type: text/plain;
1626 charset="utf-8"
1627 Content-Transfer-Encoding: quoted-printable
1628 From: richard <richard@test.test>
1629 To: issue_tracker@your.tracker.email.domain.example
1630 Message-Id: <followup_dummy_id>
1631 In-Reply-To: <dummy_test_message_id>
1632 Subject: [issue1] Testing... [assignedto=mary; nosy=+john]
1633
1634 This is a followup with UTF-8 characters in it:
1635 =C3=A4=C3=B6=C3=BC=C3=84=C3=96=C3=9C=C3=9F
1636 ''')
1637 l = self.db.issue.get('1', 'nosy')
1638 l.sort()
1639 self.assertEqual(l, [self.chef_id, self.richard_id, self.mary_id,
1640 self.john_id])
1641
1642 self.compareMessages(self._get_mail(),
1643 '''FROM: roundup-admin@your.tracker.email.domain.example
1644 TO: chef@bork.bork.bork, john@test.test, mary@test.test
1645 Content-Type: text/plain; charset="utf-8"
1646 Subject: [issue1] Testing...
1647 To: chef@bork.bork.bork, john@test.test, mary@test.test
1648 From: richard <issue_tracker@your.tracker.email.domain.example>
1649 Reply-To: Roundup issue tracker
1650 <issue_tracker@your.tracker.email.domain.example>
1651 MIME-Version: 1.0
1652 Message-Id: <followup_dummy_id>
1653 In-Reply-To: <dummy_test_message_id>
1654 X-Roundup-Name: Roundup issue tracker
1655 X-Roundup-Loop: hello
1656 X-Roundup-Issue-Status: chatting
1657 Content-Transfer-Encoding: quoted-printable
1658 X-Roundup-Issue-Id: 1
1659
1660
1661 richard <richard@test.test> added the comment:
1662
1663 This is a followup with UTF-8 characters in it:
1664 =C3=A4=C3=B6=C3=BC=C3=84=C3=96=C3=9C=C3=9F
1665
1666 ----------
1667 assignedto: -> mary
1668 nosy: +john, mary
1669 status: unread -> chatting
1670
1671 _______________________________________________________________________
1672 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
1673 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
1674 _______________________________________________________________________
1675 ''')
1676
1622 def testFollowupNoSubjectChange(self): 1677 def testFollowupNoSubjectChange(self):
1623 self.db.config.MAILGW_SUBJECT_UPDATES_TITLE = 'no' 1678 self.db.config.MAILGW_SUBJECT_UPDATES_TITLE = 'no'
1624 self.doNewIssue() 1679 self.doNewIssue()
1625 1680
1626 self._handle_mail('''Content-Type: text/plain; 1681 self._handle_mail('''Content-Type: text/plain;
4382 self.assertEqual(self.db.msg.get(msgid, 'content'), 4437 self.assertEqual(self.db.msg.get(msgid, 'content'),
4383 'Catch this exception and log it without emailing.') 4438 'Catch this exception and log it without emailing.')
4384 self.assertEqual(self.db.msg.get(msgid, 'files'), ['1']) 4439 self.assertEqual(self.db.msg.get(msgid, 'files'), ['1'])
4385 fileid = self.db.msg.get(msgid, 'files')[0] 4440 fileid = self.db.msg.get(msgid, 'files')[0]
4386 self.assertEqual(self.db.file.get(fileid, 'type'), 'message/rfc822') 4441 self.assertEqual(self.db.file.get(fileid, 'type'), 'message/rfc822')
4442
4443
4444 def testStandardMsg(self):
4445 self.instance.config['MAIL_DOMAIN'] = 'example.com'
4446 name = u'Accented chars \xe4\xf6\xfc\xc4\xd6\xdc\xdf'
4447 name = name.encode('utf-8')
4448 adr = 'someone@example.com'
4449 to = [adr]
4450 adr = (name, adr)
4451 mailer = roundupdb.Mailer(self.db.config)
4452 mailer.standard_message(to, name, name, author=adr)
4453 assert os.path.exists(SENDMAILDEBUG)
4454 self.compareMessages(self._get_mail(),
4455 '''
4456 FROM: roundup-admin@example.com
4457 TO: someone@example.com
4458 From: =?utf-8?b?QWNjZW50ZWQgY2hhcnMgw6TDtsO8w4TDlsOcw58=?=
4459 <someone@example.com>
4460 To: someone@example.com
4461 MIME-Version: 1.0
4462 Content-Type: text/plain; charset="utf-8"
4463 Subject: =?utf-8?b?QWNjZW50ZWQgY2hhcnMgw6TDtsO8w4TDlsOcw58=?=
4464 X-Roundup-Name: Roundup issue tracker
4465 X-Roundup-Loop: hello
4466 Content-Transfer-Encoding: base64
4467
4468 QWNjZW50ZWQgY2hhcnMgw6TDtsO8w4TDlsOcw58=
4469 ''')
4387 4470
4388 4471
4389 @skip_pgp 4472 @skip_pgp
4390 class MailgwPGPTestCase(MailgwTestAbstractBase, unittest.TestCase): 4473 class MailgwPGPTestCase(MailgwTestAbstractBase, unittest.TestCase):
4391 pgphome = gpgmelib.pgphome 4474 pgphome = gpgmelib.pgphome

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