comparison test/test_mailgw.py @ 602:c242455d9b46 config-0-4-0-branch

Brought the config branch up to date with HEAD
author Richard Jones <richard@users.sourceforge.net>
date Wed, 06 Feb 2002 04:05:55 +0000
parents a1a44636bace
children
comparison
equal deleted inserted replaced
601:912029653c1c 602:c242455d9b46
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.1 2002-01-02 02:31:38 richard Exp $ 11 # $Id: test_mailgw.py,v 1.1.2.1 2002-02-06 04:05:55 richard Exp $
12 12
13 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys 13 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys
14 14
15 from roundup.mailgw import MailGW 15 from roundup.mailgw import MailGW
16 from roundup import init, instance 16 from roundup import init, instance
31 self.instance = instance.open(self.dirname) 31 self.instance = instance.open(self.dirname)
32 # and open the database 32 # and open the database
33 self.db = self.instance.open('sekrit') 33 self.db = self.instance.open('sekrit')
34 self.db.user.create(username='Chef', address='chef@bork.bork.bork') 34 self.db.user.create(username='Chef', address='chef@bork.bork.bork')
35 self.db.user.create(username='richard', address='richard@test') 35 self.db.user.create(username='richard', address='richard@test')
36 self.db.user.create(username='mary', address='mary@test')
37 self.db.user.create(username='john', address='john@test')
36 38
37 def tearDown(self): 39 def tearDown(self):
38 if os.path.exists(os.environ['SENDMAILDEBUG']): 40 if os.path.exists(os.environ['SENDMAILDEBUG']):
39 os.remove(os.environ['SENDMAILDEBUG']) 41 os.remove(os.environ['SENDMAILDEBUG'])
40 try: 42 try:
63 message = cStringIO.StringIO('''Content-Type: text/plain; 65 message = cStringIO.StringIO('''Content-Type: text/plain;
64 charset="iso-8859-1" 66 charset="iso-8859-1"
65 From: Chef <chef@bork.bork.bork 67 From: Chef <chef@bork.bork.bork
66 To: issue_tracker@fill.me.in. 68 To: issue_tracker@fill.me.in.
67 Message-Id: <dummy_test_message_id> 69 Message-Id: <dummy_test_message_id>
68 Subject: [issue] Testing... 70 Subject: [issue] Testing... [nosy=mary; assignedto=richard]
69 71
70 This is a test submission of a new issue. 72 This is a test submission of a new issue.
71 ''') 73 ''')
72 handler = self.instance.MailGW(self.instance, self.db) 74 handler = self.instance.MailGW(self.instance, self.db)
73 # TODO: fix the damn config - this is apalling 75 # TODO: fix the damn config - this is apalling
74 self.instance.IssueClass.MESSAGES_TO_AUTHOR = 'yes' 76 self.db.config.MESSAGES_TO_AUTHOR = 'yes'
75 handler.main(message) 77 handler.main(message)
76 78
77 self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(), 79 self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(),
78 '''FROM: roundup-admin@fill.me.in. 80 '''FROM: roundup-admin@fill.me.in.
79 TO: chef@bork.bork.bork 81 TO: chef@bork.bork.bork, mary@test, richard@test
80 Content-Type: text/plain 82 Content-Type: text/plain
81 Subject: [issue1] Testing... 83 Subject: [issue1] Testing...
82 To: chef@bork.bork.bork 84 To: chef@bork.bork.bork, mary@test, richard@test
83 From: Chef <issue_tracker@fill.me.in.> 85 From: Chef <issue_tracker@fill.me.in.>
84 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.> 86 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.>
85 MIME-Version: 1.0 87 MIME-Version: 1.0
86 Message-Id: <dummy_test_message_id> 88 Message-Id: <dummy_test_message_id>
87 89
88 90
89 New submission from Chef <chef@bork.bork.bork>: 91 New submission from Chef <chef@bork.bork.bork>:
90 92
91 This is a test submission of a new issue. 93 This is a test submission of a new issue.
92 94
93 ___________________________________________________ 95
94 "Roundup issue tracker" <issue_tracker@fill.me.in.> 96 ----------
95 http://some.useful.url/issue1 97 assignedto: richard
96 ___________________________________________________ 98 messages: 1
97 ''', 'Generated message not correct') 99 nosy: mary, Chef, richard
100 status: unread
101 title: Testing...
102 ___________________________________________________
103 "Roundup issue tracker" <issue_tracker@fill.me.in.>
104 http://some.useful.url/issue1
105 ___________________________________________________
106 ''')
98 107
99 def testFollowup(self): 108 def testFollowup(self):
100 self.testNewIssue() 109 self.testNewIssue()
101 message = cStringIO.StringIO('''Content-Type: text/plain; 110 message = cStringIO.StringIO('''Content-Type: text/plain;
102 charset="iso-8859-1" 111 charset="iso-8859-1"
103 From: richard <richard@test> 112 From: richard <richard@test>
104 To: issue_tracker@fill.me.in. 113 To: issue_tracker@fill.me.in.
105 Message-Id: <followup_dummy_id> 114 Message-Id: <followup_dummy_id>
106 In-Reply-To: <dummy_test_message_id> 115 In-Reply-To: <dummy_test_message_id>
107 Subject: [issue1] Testing... 116 Subject: [issue1] Testing... [assignedto=mary; nosy=john]
108 117
109 This is a followup 118 This is a followup
110 ''') 119 ''')
111 handler = self.instance.MailGW(self.instance, self.db) 120 handler = self.instance.MailGW(self.instance, self.db)
112 # TODO: fix the damn config - this is apalling
113 handler.main(message) 121 handler.main(message)
114 122
115 self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(), 123 self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(),
116 '''FROM: roundup-admin@fill.me.in. 124 '''FROM: roundup-admin@fill.me.in.
117 TO: chef@bork.bork.bork 125 TO: chef@bork.bork.bork, mary@test, john@test
118 Content-Type: text/plain 126 Content-Type: text/plain
119 Subject: [issue1] Testing... 127 Subject: [issue1] Testing...
120 To: chef@bork.bork.bork 128 To: chef@bork.bork.bork, mary@test, john@test
121 From: richard <issue_tracker@fill.me.in.> 129 From: richard <issue_tracker@fill.me.in.>
122 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.> 130 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.>
123 MIME-Version: 1.0 131 MIME-Version: 1.0
124 Message-Id: <followup_dummy_id> 132 Message-Id: <followup_dummy_id>
125 In-Reply-To: <dummy_test_message_id> 133 In-Reply-To: <dummy_test_message_id>
127 135
128 richard <richard@test> added the comment: 136 richard <richard@test> added the comment:
129 137
130 This is a followup 138 This is a followup
131 139
140
141 ----------
142 assignedto: -> mary
143 nosy: +mary, john
144 status: unread -> chatting
145 ___________________________________________________
146 "Roundup issue tracker" <issue_tracker@fill.me.in.>
147 http://some.useful.url/issue1
148 ___________________________________________________
149 ''', 'Generated message not correct')
150
151 def testFollowup2(self):
152 self.testNewIssue()
153 message = cStringIO.StringIO('''Content-Type: text/plain;
154 charset="iso-8859-1"
155 From: mary <mary@test>
156 To: issue_tracker@fill.me.in.
157 Message-Id: <followup_dummy_id>
158 In-Reply-To: <dummy_test_message_id>
159 Subject: [issue1] Testing...
160
161 This is a second followup
162 ''')
163 handler = self.instance.MailGW(self.instance, self.db)
164 handler.main(message)
165 self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(),
166 '''FROM: roundup-admin@fill.me.in.
167 TO: chef@bork.bork.bork, richard@test
168 Content-Type: text/plain
169 Subject: [issue1] Testing...
170 To: chef@bork.bork.bork, richard@test
171 From: mary <issue_tracker@fill.me.in.>
172 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.>
173 MIME-Version: 1.0
174 Message-Id: <followup_dummy_id>
175 In-Reply-To: <dummy_test_message_id>
176
177
178 mary <mary@test> added the comment:
179
180 This is a second followup
181
182
183 ----------
184 status: unread -> chatting
185 ___________________________________________________
186 "Roundup issue tracker" <issue_tracker@fill.me.in.>
187 http://some.useful.url/issue1
188 ___________________________________________________
189 ''', 'Generated message not correct')
190
191 def testEnc01(self):
192 self.testNewIssue()
193 message = cStringIO.StringIO('''Content-Type: text/plain;
194 charset="iso-8859-1"
195 From: mary <mary@test>
196 To: issue_tracker@fill.me.in.
197 Message-Id: <followup_dummy_id>
198 In-Reply-To: <dummy_test_message_id>
199 Subject: [issue1] Testing...
200 Content-Type: text/plain;
201 charset="iso-8859-1"
202 Content-Transfer-Encoding: quoted-printable
203
204 A message with encoding (encoded oe =F6)
205
206 ''')
207 handler = self.instance.MailGW(self.instance, self.db)
208 handler.main(message)
209 message_data = open(os.environ['SENDMAILDEBUG']).read()
210 self.assertEqual(message_data,
211 '''FROM: roundup-admin@fill.me.in.
212 TO: chef@bork.bork.bork, richard@test
213 Content-Type: text/plain
214 Subject: [issue1] Testing...
215 To: chef@bork.bork.bork, richard@test
216 From: mary <issue_tracker@fill.me.in.>
217 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.>
218 MIME-Version: 1.0
219 Message-Id: <followup_dummy_id>
220 In-Reply-To: <dummy_test_message_id>
221
222
223 mary <mary@test> added the comment:
224
225 A message with encoding (encoded oe ö)
226
227 ----------
228 status: unread -> chatting
229 ___________________________________________________
230 "Roundup issue tracker" <issue_tracker@fill.me.in.>
231 http://some.useful.url/issue1
232 ___________________________________________________
233 ''', 'Generated message not correct')
234
235
236 def testMultipartEnc01(self):
237 self.testNewIssue()
238 message = cStringIO.StringIO('''Content-Type: text/plain;
239 charset="iso-8859-1"
240 From: mary <mary@test>
241 To: issue_tracker@fill.me.in.
242 Message-Id: <followup_dummy_id>
243 In-Reply-To: <dummy_test_message_id>
244 Subject: [issue1] Testing...
245 Content-Type: multipart/mixed;
246 boundary="----_=_NextPart_000_01"
247
248 This message is in MIME format. Since your mail reader does not understand
249 this format, some or all of this message may not be legible.
250
251 ------_=_NextPart_000_01
252 Content-Type: text/plain;
253 charset="iso-8859-1"
254 Content-Transfer-Encoding: quoted-printable
255
256 A message with first part encoded (encoded oe =F6)
257
258 ''')
259 handler = self.instance.MailGW(self.instance, self.db)
260 handler.main(message)
261 message_data = open(os.environ['SENDMAILDEBUG']).read()
262 self.assertEqual(message_data,
263 '''FROM: roundup-admin@fill.me.in.
264 TO: chef@bork.bork.bork, richard@test
265 Content-Type: text/plain
266 Subject: [issue1] Testing...
267 To: chef@bork.bork.bork, richard@test
268 From: mary <issue_tracker@fill.me.in.>
269 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.>
270 MIME-Version: 1.0
271 Message-Id: <followup_dummy_id>
272 In-Reply-To: <dummy_test_message_id>
273
274
275 mary <mary@test> added the comment:
276
277 A message with first part encoded (encoded oe ö)
278
279 ----------
280 status: unread -> chatting
132 ___________________________________________________ 281 ___________________________________________________
133 "Roundup issue tracker" <issue_tracker@fill.me.in.> 282 "Roundup issue tracker" <issue_tracker@fill.me.in.>
134 http://some.useful.url/issue1 283 http://some.useful.url/issue1
135 ___________________________________________________ 284 ___________________________________________________
136 ''', 'Generated message not correct') 285 ''', 'Generated message not correct')
138 class ExtMailgwTestCase(MailgwTestCase): 287 class ExtMailgwTestCase(MailgwTestCase):
139 schema = 'extended' 288 schema = 'extended'
140 289
141 def suite(): 290 def suite():
142 l = [unittest.makeSuite(MailgwTestCase, 'test'), 291 l = [unittest.makeSuite(MailgwTestCase, 'test'),
143 unittest.makeSuite(ExtMailgwTestCase, 'test')] 292 unittest.makeSuite(ExtMailgwTestCase, 'test')
293 ]
144 return unittest.TestSuite(l) 294 return unittest.TestSuite(l)
145 295
146 296
147 # 297 #
148 # $Log: not supported by cvs2svn $ 298 # $Log: not supported by cvs2svn $
299 # Revision 1.9 2002/02/05 14:15:29 grubert
300 # . respect encodings in non multipart messages.
301 #
302 # Revision 1.8 2002/02/04 09:40:21 grubert
303 # . add test for multipart messages with first part being encoded.
304 #
305 # Revision 1.7 2002/01/22 11:54:45 rochecompaan
306 # Fixed status change in mail gateway.
307 #
308 # Revision 1.6 2002/01/21 10:05:48 rochecompaan
309 # Feature:
310 # . the mail gateway now responds with an error message when invalid
311 # values for arguments are specified for link or multilink properties
312 # . modified unit test to check nosy and assignedto when specified as
313 # arguments
314 #
315 # Fixed:
316 # . fixed setting nosy as argument in subject line
317 #
318 # Revision 1.5 2002/01/15 00:12:40 richard
319 # #503340 ] creating issue with [asignedto=p.ohly]
320 #
321 # Revision 1.4 2002/01/14 07:12:15 richard
322 # removed file writing from tests...
323 #
324 # Revision 1.3 2002/01/14 02:20:15 richard
325 # . changed all config accesses so they access either the instance or the
326 # config attriubute on the db. This means that all config is obtained from
327 # instance_config instead of the mish-mash of classes. This will make
328 # switching to a ConfigParser setup easier too, I hope.
329 #
330 # At a minimum, this makes migration a _little_ easier (a lot easier in the
331 # 0.5.0 switch, I hope!)
332 #
333 # Revision 1.2 2002/01/11 23:22:29 richard
334 # . #502437 ] rogue reactor and unittest
335 # in short, the nosy reactor was modifying the nosy list. That code had
336 # been there for a long time, and I suspsect it was there because we
337 # weren't generating the nosy list correctly in other places of the code.
338 # We're now doing that, so the nosy-modifying code can go away from the
339 # nosy reactor.
340 #
341 # Revision 1.1 2002/01/02 02:31:38 richard
342 # Sorry for the huge checkin message - I was only intending to implement #496356
343 # but I found a number of places where things had been broken by transactions:
344 # . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename
345 # for _all_ roundup-generated smtp messages to be sent to.
346 # . the transaction cache had broken the roundupdb.Class set() reactors
347 # . newly-created author users in the mailgw weren't being committed to the db
348 #
349 # Stuff that made it into CHANGES.txt (ie. the stuff I was actually working
350 # on when I found that stuff :):
351 # . #496356 ] Use threading in messages
352 # . detectors were being registered multiple times
353 # . added tests for mailgw
354 # . much better attaching of erroneous messages in the mail gateway
355 #
149 # 356 #
150 # 357 #
151 # 358 #
152 # vim: set filetype=python ts=4 sw=4 et si 359 # vim: set filetype=python ts=4 sw=4 et si

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