Mercurial > p > roundup > code
changeset 1887:9d8d5fa0d9ad
Don't rely on being about an issue...
...when submitting a message to the mail gateway.
| author | Johannes Gijsbers <jlgijsbers@users.sourceforge.net> |
|---|---|
| date | Mon, 03 Nov 2003 18:34:03 +0000 |
| parents | e3cff1bb1b86 |
| children | 465dc7dbe67a |
| files | roundup/mailgw.py test/test_mailgw.py |
| diffstat | 2 files changed, 36 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/mailgw.py Mon Nov 03 10:33:23 2003 +0000 +++ b/roundup/mailgw.py Mon Nov 03 18:34:03 2003 +0000 @@ -73,7 +73,7 @@ an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.135 2003-10-25 12:03:41 jlgijsbers Exp $ +$Id: mailgw.py,v 1.136 2003-11-03 18:34:03 jlgijsbers Exp $ """ import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri @@ -789,27 +789,27 @@ # # handle the attachments # - files = [] - for (name, mime_type, data) in attachments: - if not name: - name = "unnamed" - files.append(self.db.file.create(type=mime_type, name=name, - content=data, **file_props)) - # attach the files to the issue - if nodeid: - # extend the existing files list - fileprop = cl.get(nodeid, 'files') - fileprop.extend(files) - props['files'] = fileprop - else: - # pre-load the files list - props['files'] = files - + if properties.has_key('files'): + files = [] + for (name, mime_type, data) in attachments: + if not name: + name = "unnamed" + files.append(self.db.file.create(type=mime_type, name=name, + content=data, **file_props)) + # attach the files to the issue + if nodeid: + # extend the existing files list + fileprop = cl.get(nodeid, 'files') + fileprop.extend(files) + props['files'] = fileprop + else: + # pre-load the files list + props['files'] = files # # create the message if there's a message body (content) # - if content: + if (content and properties.has_key('messages')): message_id = self.db.msg.create(author=author, recipients=recipients, date=date.Date('.'), summary=summary, content=content, files=files, messageid=messageid,
--- a/test/test_mailgw.py Mon Nov 03 10:33:23 2003 +0000 +++ b/test/test_mailgw.py Mon Nov 03 18:34:03 2003 +0000 @@ -8,7 +8,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_mailgw.py,v 1.57 2003-10-25 22:53:26 richard Exp $ +# $Id: test_mailgw.py,v 1.58 2003-11-03 18:34:03 jlgijsbers Exp $ import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 @@ -997,6 +997,23 @@ self.db.user.lookup('johannes') + def testFollowupOnNonIssue(self): + self.db.keyword.create(name='Foo') + message = StringIO('''Content-Type: text/plain; + charset="iso-8859-1" +From: richard <richard@test> +To: issue_tracker@your.tracker.email.domain.example +Message-Id: <followup_dummy_id> +In-Reply-To: <dummy_test_message_id> +Subject: [keyword1] Testing... [name=Bar] + +''') + handler = self.instance.MailGW(self.instance, self.db) + handler.trapExceptions = 0 + handler.main(message) + + self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar') + def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(MailgwTestCase))
