Code

Extract _send_mail method, it was duplicated all around the test code.
[roundup.git] / test / test_mailgw.py
index 2fce57d68ea4d083c7df004544e72679905d5034..4a1991ec776cc39408f8af9ca6b13f6c4b82eda1 100644 (file)
@@ -8,15 +8,20 @@
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 #
-# $Id: test_mailgw.py,v 1.50 2003-09-07 18:27:47 jlgijsbers Exp $
+# $Id: test_mailgw.py,v 1.59 2003-11-03 19:08:41 jlgijsbers Exp $
 
 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822
 
 from cStringIO import StringIO
 
-from roundup.mailgw import MailGW, Unauthorized, uidFromAddress
+if not os.environ.has_key('SENDMAILDEBUG'):
+    os.environ['SENDMAILDEBUG'] = 'mail-test.log'
+SENDMAILDEBUG = os.environ['SENDMAILDEBUG']
+
+from roundup.mailgw import MailGW, Unauthorized, uidFromAddress, parseContent
 from roundup import init, instance, rfc2822
 
+
 class Message(rfc822.Message):
     """String-based Message class with equivalence test."""
     def __init__(self, s):
@@ -80,8 +85,10 @@ class MailgwTestCase(unittest.TestCase, DiffHelper):
         init.install(self.dirname, 'templates/classic')
         init.write_select_db(self.dirname, 'anydbm')
         init.initialise(self.dirname, 'sekrit')
+        
         # check we can load the package
         self.instance = instance.open(self.dirname)
+
         # and open the database
         self.db = self.instance.open('admin')
         self.db.user.create(username='Chef', address='chef@bork.bork.bork',
@@ -95,16 +102,28 @@ class MailgwTestCase(unittest.TestCase, DiffHelper):
             realname='John Doe')
 
     def tearDown(self):
-        if os.path.exists(os.environ['SENDMAILDEBUG']):
-            os.remove(os.environ['SENDMAILDEBUG'])
+        if os.path.exists(SENDMAILDEBUG):
+            os.remove(SENDMAILDEBUG)
         self.db.close()
         try:
             shutil.rmtree(self.dirname)
         except OSError, error:
             if error.errno not in (errno.ENOENT, errno.ESRCH): raise
 
+    def _send_mail(self, message):
+        handler = self.instance.MailGW(self.instance, self.db)
+        handler.trapExceptions = 0
+        return handler.main(StringIO(message))
+        
+    def _get_mail(self):
+        f = open(SENDMAILDEBUG)
+        try:
+            return f.read()
+        finally:
+            f.close()
+
     def testEmptyMessage(self):
-        message = StringIO('''Content-Type: text/plain;
+        nodeid = self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: Chef <chef@bork.bork.bork>
 To: issue_tracker@your.tracker.email.domain.example
@@ -113,16 +132,11 @@ Message-Id: <dummy_test_message_id>
 Subject: [issue] Testing...
 
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        nodeid = handler.main(message)
-        if os.path.exists(os.environ['SENDMAILDEBUG']):
-            error = open(os.environ['SENDMAILDEBUG']).read()
-            self.assertEqual('no error', error)
+        assert not os.path.exists(SENDMAILDEBUG)
         self.assertEqual(self.db.issue.get(nodeid, 'title'), 'Testing...')
 
     def doNewIssue(self):
-        message = StringIO('''Content-Type: text/plain;
+        nodeid = self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: Chef <chef@bork.bork.bork>
 To: issue_tracker@your.tracker.email.domain.example
@@ -132,12 +146,7 @@ Subject: [issue] Testing...
 
 This is a test submission of a new issue.
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        nodeid = handler.main(message)
-        if os.path.exists(os.environ['SENDMAILDEBUG']):
-            error = open(os.environ['SENDMAILDEBUG']).read()
-            self.assertEqual('no error', error)
+        assert not os.path.exists(SENDMAILDEBUG)
         l = self.db.issue.get(nodeid, 'nosy')
         l.sort()
         self.assertEqual(l, ['3', '4'])
@@ -148,7 +157,7 @@ This is a test submission of a new issue.
 
     def testNewIssueNosy(self):
         self.instance.config.ADD_AUTHOR_TO_NOSY = 'yes'
-        message = StringIO('''Content-Type: text/plain;
+        nodeid = self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: Chef <chef@bork.bork.bork>
 To: issue_tracker@your.tracker.email.domain.example
@@ -158,18 +167,13 @@ Subject: [issue] Testing...
 
 This is a test submission of a new issue.
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        nodeid = handler.main(message)
-        if os.path.exists(os.environ['SENDMAILDEBUG']):
-            error = open(os.environ['SENDMAILDEBUG']).read()
-            self.assertEqual('no error', error)
+        assert not os.path.exists(SENDMAILDEBUG)
         l = self.db.issue.get(nodeid, 'nosy')
         l.sort()
         self.assertEqual(l, ['3', '4'])
 
     def testAlternateAddress(self):
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: John Doe <john.doe@test>
 To: issue_tracker@your.tracker.email.domain.example
@@ -178,18 +182,13 @@ Subject: [issue] Testing...
 
 This is a test submission of a new issue.
 ''')
-        userlist = self.db.user.list()
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-        if os.path.exists(os.environ['SENDMAILDEBUG']):
-            error = open(os.environ['SENDMAILDEBUG']).read()
-            self.assertEqual('no error', error)
+        userlist = self.db.user.list()        
+        assert not os.path.exists(SENDMAILDEBUG)
         self.assertEqual(userlist, self.db.user.list(),
             "user created when it shouldn't have been")
 
     def testNewIssueNoClass(self):
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: Chef <chef@bork.bork.bork>
 To: issue_tracker@your.tracker.email.domain.example
@@ -199,15 +198,12 @@ Subject: Testing...
 
 This is a test submission of a new issue.
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-        if os.path.exists(os.environ['SENDMAILDEBUG']):
-            error = open(os.environ['SENDMAILDEBUG']).read()
-            self.assertEqual('no error', error)
+        assert not os.path.exists(SENDMAILDEBUG)
 
     def testNewIssueAuthMsg(self):
-        message = StringIO('''Content-Type: text/plain;
+        # TODO: fix the damn config - this is apalling
+        self.db.config.MESSAGES_TO_AUTHOR = 'yes'
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: Chef <chef@bork.bork.bork>
 To: issue_tracker@your.tracker.email.domain.example
@@ -216,13 +212,7 @@ Subject: [issue] Testing... [nosy=mary; assignedto=richard]
 
 This is a test submission of a new issue.
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        # TODO: fix the damn config - this is apalling
-        self.db.config.MESSAGES_TO_AUTHOR = 'yes'
-        handler.main(message)
-
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork, mary@test, richard@test
 Content-Type: text/plain; charset=utf-8
@@ -264,7 +254,7 @@ _______________________________________________________________________
 
     def testSimpleFollowup(self):
         self.doNewIssue()
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: mary <mary@test>
 To: issue_tracker@your.tracker.email.domain.example
@@ -274,10 +264,7 @@ Subject: [issue1] Testing...
 
 This is a second followup
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork, richard@test
 Content-Type: text/plain; charset=utf-8
@@ -308,7 +295,7 @@ _______________________________________________________________________
     def testFollowup(self):
         self.doNewIssue()
 
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: richard <richard@test>
 To: issue_tracker@your.tracker.email.domain.example
@@ -318,14 +305,11 @@ Subject: [issue1] Testing... [assignedto=mary; nosy=+john]
 
 This is a followup
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
         l = self.db.issue.get('1', 'nosy')
         l.sort()
         self.assertEqual(l, ['3', '4', '5', '6'])
 
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork, john@test, mary@test
 Content-Type: text/plain; charset=utf-8
@@ -357,7 +341,7 @@ _______________________________________________________________________
 
     def testFollowupTitleMatch(self):
         self.doNewIssue()
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: richard <richard@test>
 To: issue_tracker@your.tracker.email.domain.example
@@ -367,11 +351,7 @@ Subject: Re: Testing... [assignedto=mary; nosy=+john]
 
 This is a followup
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork, john@test, mary@test
 Content-Type: text/plain; charset=utf-8
@@ -404,7 +384,7 @@ _______________________________________________________________________
     def testFollowupNosyAuthor(self):
         self.doNewIssue()
         self.db.config.ADD_AUTHOR_TO_NOSY = 'yes'
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: john@test
 To: issue_tracker@your.tracker.email.domain.example
@@ -414,11 +394,8 @@ Subject: [issue1] Testing...
 
 This is a followup
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
 
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork, richard@test
 Content-Type: text/plain; charset=utf-8
@@ -451,7 +428,7 @@ _______________________________________________________________________
     def testFollowupNosyRecipients(self):
         self.doNewIssue()
         self.db.config.ADD_RECIPIENTS_TO_NOSY = 'yes'
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: richard@test
 To: issue_tracker@your.tracker.email.domain.example
@@ -462,11 +439,7 @@ Subject: [issue1] Testing...
 
 This is a followup
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork
 Content-Type: text/plain; charset=utf-8
@@ -500,7 +473,7 @@ _______________________________________________________________________
         self.doNewIssue()
         self.db.config.ADD_AUTHOR_TO_NOSY = 'yes'
         self.db.config.MESSAGES_TO_AUTHOR = 'yes'
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: john@test
 To: issue_tracker@your.tracker.email.domain.example
@@ -510,11 +483,7 @@ Subject: [issue1] Testing...
 
 This is a followup
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork, john@test, richard@test
 Content-Type: text/plain; charset=utf-8
@@ -547,7 +516,7 @@ _______________________________________________________________________
     def testFollowupNoNosyAuthor(self):
         self.doNewIssue()
         self.instance.config.ADD_AUTHOR_TO_NOSY = 'no'
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: john@test
 To: issue_tracker@your.tracker.email.domain.example
@@ -557,11 +526,7 @@ Subject: [issue1] Testing...
 
 This is a followup
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork, richard@test
 Content-Type: text/plain; charset=utf-8
@@ -593,7 +558,7 @@ _______________________________________________________________________
     def testFollowupNoNosyRecipients(self):
         self.doNewIssue()
         self.instance.config.ADD_RECIPIENTS_TO_NOSY = 'no'
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: richard@test
 To: issue_tracker@your.tracker.email.domain.example
@@ -604,11 +569,7 @@ Subject: [issue1] Testing...
 
 This is a followup
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork
 Content-Type: text/plain; charset=utf-8
@@ -640,7 +601,7 @@ _______________________________________________________________________
     def testFollowupEmptyMessage(self):
         self.doNewIssue()
 
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: richard <richard@test>
 To: issue_tracker@your.tracker.email.domain.example
@@ -649,20 +610,17 @@ In-Reply-To: <dummy_test_message_id>
 Subject: [issue1] Testing... [assignedto=mary; nosy=+john]
 
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
         l = self.db.issue.get('1', 'nosy')
         l.sort()
         self.assertEqual(l, ['3', '4', '5', '6'])
 
         # should be no file created (ie. no message)
-        assert not os.path.exists(os.environ['SENDMAILDEBUG'])
+        assert not os.path.exists(SENDMAILDEBUG)
 
     def testNosyRemove(self):
         self.doNewIssue()
 
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: richard <richard@test>
 To: issue_tracker@your.tracker.email.domain.example
@@ -671,15 +629,12 @@ In-Reply-To: <dummy_test_message_id>
 Subject: [issue1] Testing... [nosy=-richard]
 
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
         l = self.db.issue.get('1', 'nosy')
         l.sort()
         self.assertEqual(l, ['3'])
 
         # NO NOSY MESSAGE SHOULD BE SENT!
-        self.assert_(not os.path.exists(os.environ['SENDMAILDEBUG']))
+        assert not os.path.exists(SENDMAILDEBUG)
 
     def testNewUserAuthor(self):
         # first without the permission
@@ -691,7 +646,7 @@ Subject: [issue1] Testing... [nosy=-richard]
         self.db.security.hasPermission('Email Registration', anonid)
         l = self.db.user.list()
         l.sort()
-        s = '''Content-Type: text/plain;
+        message = '''Content-Type: text/plain;
   charset="iso-8859-1"
 From: fubar <fubar@bork.bork.bork>
 To: issue_tracker@your.tracker.email.domain.example
@@ -700,10 +655,7 @@ Subject: [issue] Testing...
 
 This is a test submission of a new issue.
 '''
-        message = StringIO(s)
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        self.assertRaises(Unauthorized, handler.main, message)
+        self.assertRaises(Unauthorized, self._send_mail, message)
         m = self.db.user.list()
         m.sort()
         self.assertEqual(l, m)
@@ -711,17 +663,14 @@ This is a test submission of a new issue.
         # now with the permission
         p = self.db.security.getPermission('Email Registration')
         self.db.security.role['anonymous'].permissions=[p]
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        message = StringIO(s)
-        handler.main(message)
+        self._send_mail(message)
         m = self.db.user.list()
         m.sort()
         self.assertNotEqual(l, m)
 
     def testEnc01(self):
         self.doNewIssue()
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: mary <mary@test>
 To: issue_tracker@your.tracker.email.domain.example
@@ -735,10 +684,7 @@ Content-Transfer-Encoding: quoted-printable
 A message with encoding (encoded oe =F6)
 
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork, richard@test
 Content-Type: text/plain; charset=utf-8
@@ -769,7 +715,7 @@ _______________________________________________________________________
 
     def testMultipartEnc01(self):
         self.doNewIssue()
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: mary <mary@test>
 To: issue_tracker@your.tracker.email.domain.example
@@ -790,10 +736,7 @@ Content-Transfer-Encoding: quoted-printable
 A message with first part encoded (encoded oe =F6)
 
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork, richard@test
 Content-Type: text/plain; charset=utf-8
@@ -823,7 +766,7 @@ _______________________________________________________________________
 
     def testContentDisposition(self):
         self.doNewIssue()
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: mary <mary@test>
 To: issue_tracker@your.tracker.email.domain.example
@@ -848,9 +791,6 @@ xxxxxx
 
 --bCsyhTFzCvuiizWE--
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
         messages = self.db.issue.get('1', 'messages')
         messages.sort()
         file = self.db.msg.get(messages[-1], 'files')[0]
@@ -859,7 +799,7 @@ xxxxxx
     def testFollowupStupidQuoting(self):
         self.doNewIssue()
 
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: richard <richard@test>
 To: issue_tracker@your.tracker.email.domain.example
@@ -869,11 +809,7 @@ Subject: Re: "[issue1] Testing... "
 
 This is a followup
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-
-        self.compareMessages(open(os.environ['SENDMAILDEBUG']).read(),
+        self.compareMessages(self._get_mail(),
 '''FROM: roundup-admin@your.tracker.email.domain.example
 TO: chef@bork.bork.bork
 Content-Type: text/plain; charset=utf-8
@@ -921,7 +857,7 @@ This is a followup
 
         messages = self.db.issue.get(nodeid, 'messages')
 
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: richard <richard@test>
 To: issue_tracker@your.tracker.email.domain.example
@@ -936,10 +872,6 @@ Blah blah wrote:
 
 This is a followup
 ''')
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-
         # figure the new message id
         newmessages = self.db.issue.get(nodeid, 'messages')
         for msg in messages:
@@ -956,6 +888,12 @@ This is a followup
         self.assertEqual(uidFromAddress(self.db, ('', 'USER2@foo.com'), 0), i)
         self.assertEqual(uidFromAddress(self.db, ('', 'user2@foo.com'), 0), i)
 
+    def testUserAlternateLookup(self):
+        i = self.db.user.create(username='user1', address='user1@foo.com',
+                                alternate_addresses='user1@bar.com')
+        self.assertEqual(uidFromAddress(self.db, ('', 'user1@bar.com'), 0), i)
+        self.assertEqual(uidFromAddress(self.db, ('', 'USER1@bar.com'), 0), i)
+
     def testUserCreate(self):
         i = uidFromAddress(self.db, ('', 'user@foo.com'), 1)
         self.assertNotEqual(uidFromAddress(self.db, ('', 'user@bar.com'), 1), i)
@@ -970,7 +908,7 @@ This is a followup
     def testRegistrationConfirmation(self):
         otk = "Aj4euk4LZSAdwePohj90SME5SpopLETL"
         self.db.otks.set(otk, username='johannes', __time='')
-        message = StringIO('''Content-Type: text/plain;
+        self._send_mail('''Content-Type: text/plain;
   charset="iso-8859-1"
 From: Chef <chef@bork.bork.bork>
 To: issue_tracker@your.tracker.email.domain.example
@@ -981,16 +919,28 @@ Subject: Re: Complete your registration to Roundup issue tracker
 
 This is a test confirmation of registration.
 ''' % otk)
-        handler = self.instance.MailGW(self.instance, self.db)
-        handler.trapExceptions = 0
-        handler.main(message)
-
         self.db.user.lookup('johannes')
-    
-def suite():
-    l = [unittest.makeSuite(MailgwTestCase),
-    ]
-    return unittest.TestSuite(l)
 
+    def testFollowupOnNonIssue(self):
+        self.db.keyword.create(name='Foo')
+        self._send_mail('''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]
+
+''')        
+        self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar')
+    
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(MailgwTestCase))
+    return suite
+
+if __name__ == '__main__':
+    runner = unittest.TextTestRunner()
+    unittest.main(testRunner=runner)
 
 # vim: set filetype=python ts=4 sw=4 et si