comparison test/test_mailgw.py @ 1915:20cfd25cffda

Resent-From: header
author Richard Jones <richard@users.sourceforge.net>
date Thu, 13 Nov 2003 03:41:38 +0000
parents dc43e339e607
children 7e4058dfb29b
comparison
equal deleted inserted replaced
1914:3f2d1671ec03 1915:20cfd25cffda
6 # 6 #
7 # This module is distributed in the hope that it will be useful, 7 # This module is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 # 10 #
11 # $Id: test_mailgw.py,v 1.61 2003-11-11 00:35:14 richard Exp $ 11 # $Id: test_mailgw.py,v 1.62 2003-11-13 03:41:38 richard Exp $
12 12
13 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 13 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822
14 14
15 from cStringIO import StringIO 15 from cStringIO import StringIO
16 16
97 # check we can load the package 97 # check we can load the package
98 self.instance = instance.open(self.dirname) 98 self.instance = instance.open(self.dirname)
99 99
100 # and open the database 100 # and open the database
101 self.db = self.instance.open('admin') 101 self.db = self.instance.open('admin')
102 self.db.user.create(username='Chef', address='chef@bork.bork.bork', 102 self.chef_id = self.db.user.create(username='Chef',
103 realname='Bork, Chef', roles='User') 103 address='chef@bork.bork.bork', realname='Bork, Chef', roles='User')
104 self.db.user.create(username='richard', address='richard@test', 104 self.richard_id = self.db.user.create(username='richard',
105 roles='User') 105 address='richard@test', roles='User')
106 self.db.user.create(username='mary', address='mary@test', 106 self.mary_id = self.db.user.create(username='mary', address='mary@test',
107 roles='User', realname='Contrary, Mary') 107 roles='User', realname='Contrary, Mary')
108 self.db.user.create(username='john', address='john@test', 108 self.john_id = self.db.user.create(username='john', address='john@test',
109 alternate_addresses='jondoe@test\njohn.doe@test', roles='User', 109 alternate_addresses='jondoe@test\njohn.doe@test', roles='User',
110 realname='John Doe') 110 realname='John Doe')
111 111
112 def tearDown(self): 112 def tearDown(self):
113 if os.path.exists(SENDMAILDEBUG): 113 if os.path.exists(SENDMAILDEBUG):
155 This is a test submission of a new issue. 155 This is a test submission of a new issue.
156 ''') 156 ''')
157 assert not os.path.exists(SENDMAILDEBUG) 157 assert not os.path.exists(SENDMAILDEBUG)
158 l = self.db.issue.get(nodeid, 'nosy') 158 l = self.db.issue.get(nodeid, 'nosy')
159 l.sort() 159 l.sort()
160 self.assertEqual(l, ['3', '4']) 160 self.assertEqual(l, [self.chef_id, self.richard_id])
161 return nodeid 161 return nodeid
162 162
163 def testNewIssue(self): 163 def testNewIssue(self):
164 self.doNewIssue() 164 self.doNewIssue()
165 165
176 This is a test submission of a new issue. 176 This is a test submission of a new issue.
177 ''') 177 ''')
178 assert not os.path.exists(SENDMAILDEBUG) 178 assert not os.path.exists(SENDMAILDEBUG)
179 l = self.db.issue.get(nodeid, 'nosy') 179 l = self.db.issue.get(nodeid, 'nosy')
180 l.sort() 180 l.sort()
181 self.assertEqual(l, ['3', '4']) 181 self.assertEqual(l, [self.chef_id, self.richard_id])
182 182
183 def testAlternateAddress(self): 183 def testAlternateAddress(self):
184 self._send_mail('''Content-Type: text/plain; 184 self._send_mail('''Content-Type: text/plain;
185 charset="iso-8859-1" 185 charset="iso-8859-1"
186 From: John Doe <john.doe@test> 186 From: John Doe <john.doe@test>
313 313
314 This is a followup 314 This is a followup
315 ''') 315 ''')
316 l = self.db.issue.get('1', 'nosy') 316 l = self.db.issue.get('1', 'nosy')
317 l.sort() 317 l.sort()
318 self.assertEqual(l, ['3', '4', '5', '6']) 318 self.assertEqual(l, [self.chef_id, self.richard_id, self.mary_id,
319 self.john_id])
319 320
320 self.compareMessages(self._get_mail(), 321 self.compareMessages(self._get_mail(),
321 '''FROM: roundup-admin@your.tracker.email.domain.example 322 '''FROM: roundup-admin@your.tracker.email.domain.example
322 TO: chef@bork.bork.bork, john@test, mary@test 323 TO: chef@bork.bork.bork, john@test, mary@test
323 Content-Type: text/plain; charset=utf-8 324 Content-Type: text/plain; charset=utf-8
618 Subject: [issue1] Testing... [assignedto=mary; nosy=+john] 619 Subject: [issue1] Testing... [assignedto=mary; nosy=+john]
619 620
620 ''') 621 ''')
621 l = self.db.issue.get('1', 'nosy') 622 l = self.db.issue.get('1', 'nosy')
622 l.sort() 623 l.sort()
623 self.assertEqual(l, ['3', '4', '5', '6']) 624 self.assertEqual(l, [self.chef_id, self.richard_id, self.mary_id,
625 self.john_id])
624 626
625 # should be no file created (ie. no message) 627 # should be no file created (ie. no message)
626 assert not os.path.exists(SENDMAILDEBUG) 628 assert not os.path.exists(SENDMAILDEBUG)
627 629
628 def testNosyRemove(self): 630 def testNosyRemove(self):
637 Subject: [issue1] Testing... [nosy=-richard] 639 Subject: [issue1] Testing... [nosy=-richard]
638 640
639 ''') 641 ''')
640 l = self.db.issue.get('1', 'nosy') 642 l = self.db.issue.get('1', 'nosy')
641 l.sort() 643 l.sort()
642 self.assertEqual(l, ['3']) 644 self.assertEqual(l, [self.chef_id])
643 645
644 # NO NOSY MESSAGE SHOULD BE SENT! 646 # NO NOSY MESSAGE SHOULD BE SENT!
645 assert not os.path.exists(SENDMAILDEBUG) 647 assert not os.path.exists(SENDMAILDEBUG)
646 648
647 def testNewUserAuthor(self): 649 def testNewUserAuthor(self):
939 In-Reply-To: <dummy_test_message_id> 941 In-Reply-To: <dummy_test_message_id>
940 Subject: [keyword1] Testing... [name=Bar] 942 Subject: [keyword1] Testing... [name=Bar]
941 943
942 ''') 944 ''')
943 self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar') 945 self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar')
946
947 def testResentFrom(self):
948 nodeid = self._send_mail('''Content-Type: text/plain;
949 charset="iso-8859-1"
950 From: Chef <chef@bork.bork.bork>
951 Resent-From: mary <mary@test>
952 To: issue_tracker@your.tracker.email.domain.example
953 Cc: richard@test
954 Message-Id: <dummy_test_message_id>
955 Subject: [issue] Testing...
956
957 This is a test submission of a new issue.
958 ''')
959 assert not os.path.exists(SENDMAILDEBUG)
960 l = self.db.issue.get(nodeid, 'nosy')
961 l.sort()
962 self.assertEqual(l, [self.richard_id, self.mary_id])
963 return nodeid
944 964
945 def test_suite(): 965 def test_suite():
946 suite = unittest.TestSuite() 966 suite = unittest.TestSuite()
947 suite.addTest(unittest.makeSuite(MailgwTestCase)) 967 suite.addTest(unittest.makeSuite(MailgwTestCase))
948 return suite 968 return suite

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