comparison test/test_mailgw.py @ 5545:4523fe3cf04c

Add failing transcoding test An attachment with Content-Type application/octet is transcoded to utf-8, originally the attachment is in latin1 (although that doen't matter, no charset can be asumed for a binary-only attachment).
author Ralf Schlatterbeck <rsc@runtux.com>
date Tue, 25 Sep 2018 17:03:19 +0200
parents 29346d92d80c
children 52e50ab5dfda
comparison
equal deleted inserted replaced
5544:1a0498c1ed90 5545:4523fe3cf04c
666 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example> 666 Roundup issue tracker <issue_tracker@your.tracker.email.domain.example>
667 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1> 667 <http://tracker.example/cgi-bin/roundup.cgi/bugs/issue1>
668 _______________________________________________________________________ 668 _______________________________________________________________________
669 ''') 669 ''')
670 670
671 octetstream_msg = '''From: mary <mary@test.test>
672 To: issue_tracker@your.tracker.email.domain.example
673 Message-Id: <followup_dummy_id>
674 In-Reply-To: <dummy_test_message_id>
675 Subject: [issue1] Testing...
676 Content-Type: multipart/mixed; boundary="uh56ypi7view24rr"
677 Content-Disposition: inline
678
679 --uh56ypi7view24rr
680 Content-Type: text/plain; charset=us-ascii
681 Content-Disposition: inline
682
683 Attach a file with non-ascii characters in it (encoded latin-1 should
684 make it as-is through roundup due to Content-Type
685 application/octet-stream)
686 --
687 Ralf Schlatterbeck email: ralf@zoo.priv.at
688
689 --uh56ypi7view24rr
690 Content-Type: application/octet-stream
691 Content-Disposition: attachment; filename=testfile
692 Content-Transfer-Encoding: quoted-printable
693
694 This is a file containing text
695 in latin-1 format =E4=F6=FC=C4=D6=DC=DF
696
697 --uh56ypi7view24rr--
698 '''
699
671 multipart_msg = '''From: mary <mary@test.test> 700 multipart_msg = '''From: mary <mary@test.test>
672 To: issue_tracker@your.tracker.email.domain.example 701 To: issue_tracker@your.tracker.email.domain.example
673 Message-Id: <followup_dummy_id> 702 Message-Id: <followup_dummy_id>
674 In-Reply-To: <dummy_test_message_id> 703 In-Reply-To: <dummy_test_message_id>
675 Subject: [issue1] Testing... 704 Subject: [issue1] Testing...
800 829
801 --090500050101020406060002-- 830 --090500050101020406060002--
802 831
803 --001485f339f8f361fb049188dbba-- 832 --001485f339f8f361fb049188dbba--
804 ''' 833 '''
834
835 def testOctetStreamTranscoding(self):
836 self.doNewIssue()
837 self._handle_mail(self.octetstream_msg)
838 messages = self.db.issue.get('1', 'messages')
839 messages.sort()
840 msg = self.db.msg.getnode (messages[-1])
841 assert(len(msg.files) == 1)
842 names = {0 : 'testfile'}
843 content = ['''This is a file containing text
844 in latin-1 format \xE4\xF6\xFC\xC4\xD6\xDC\xDF
845 ''']
846 for n, id in enumerate (msg.files):
847 f = self.db.file.getnode (id)
848 self.assertEqual(f.name, names.get (n, 'unnamed'))
849 self.assertEqual(f.content, content [n])
805 850
806 def testMultipartKeepAlternatives(self): 851 def testMultipartKeepAlternatives(self):
807 self.doNewIssue() 852 self.doNewIssue()
808 self._handle_mail(self.multipart_msg) 853 self._handle_mail(self.multipart_msg)
809 messages = self.db.issue.get('1', 'messages') 854 messages = self.db.issue.get('1', 'messages')

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