Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 522:f2edf460b0b9
[SF#502437] rogue reactor and unittest
in short, the nosy reactor was modifying the nosy list. That code had
been there for a long time, and I suspect it was there because we
weren't generating the nosy list correctly in other places of the code.
We're now doing that, so the nosy-modifying code can go away from the
nosy reactor.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 11 Jan 2002 23:22:29 +0000 |
| parents | a1a44636bace |
| children | dce4c75bef5a |
comparison
equal
deleted
inserted
replaced
| 521:1416195a830d | 522:f2edf460b0b9 |
|---|---|
| 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.2 2002-01-11 23:22:29 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: |
| 133 "Roundup issue tracker" <issue_tracker@fill.me.in.> | 135 "Roundup issue tracker" <issue_tracker@fill.me.in.> |
| 134 http://some.useful.url/issue1 | 136 http://some.useful.url/issue1 |
| 135 ___________________________________________________ | 137 ___________________________________________________ |
| 136 ''', 'Generated message not correct') | 138 ''', 'Generated message not correct') |
| 137 | 139 |
| 140 def testFollowup2(self): | |
| 141 self.testNewIssue() | |
| 142 message = cStringIO.StringIO('''Content-Type: text/plain; | |
| 143 charset="iso-8859-1" | |
| 144 From: mary <mary@test> | |
| 145 To: issue_tracker@fill.me.in. | |
| 146 Message-Id: <followup_dummy_id> | |
| 147 In-Reply-To: <dummy_test_message_id> | |
| 148 Subject: [issue1] Testing... | |
| 149 | |
| 150 This is a second followup | |
| 151 ''') | |
| 152 handler = self.instance.MailGW(self.instance, self.db) | |
| 153 # TODO: fix the damn config - this is apalling | |
| 154 handler.main(message) | |
| 155 fname = 'fw2_%s.output'%self.count | |
| 156 open(fname,"w").write(open(os.environ['SENDMAILDEBUG']).read()) | |
| 157 self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(), | |
| 158 '''FROM: roundup-admin@fill.me.in. | |
| 159 TO: chef@bork.bork.bork, richard@test | |
| 160 Content-Type: text/plain | |
| 161 Subject: [issue1] Testing... | |
| 162 To: chef@bork.bork.bork, richard@test | |
| 163 From: mary <issue_tracker@fill.me.in.> | |
| 164 Reply-To: Roundup issue tracker <issue_tracker@fill.me.in.> | |
| 165 MIME-Version: 1.0 | |
| 166 Message-Id: <followup_dummy_id> | |
| 167 In-Reply-To: <dummy_test_message_id> | |
| 168 | |
| 169 | |
| 170 mary <mary@test> added the comment: | |
| 171 | |
| 172 This is a second followup | |
| 173 | |
| 174 ___________________________________________________ | |
| 175 "Roundup issue tracker" <issue_tracker@fill.me.in.> | |
| 176 http://some.useful.url/issue1 | |
| 177 ___________________________________________________ | |
| 178 ''', 'Generated message not correct') | |
| 179 | |
| 138 class ExtMailgwTestCase(MailgwTestCase): | 180 class ExtMailgwTestCase(MailgwTestCase): |
| 139 schema = 'extended' | 181 schema = 'extended' |
| 140 | 182 |
| 141 def suite(): | 183 def suite(): |
| 142 l = [unittest.makeSuite(MailgwTestCase, 'test'), | 184 l = [unittest.makeSuite(MailgwTestCase, 'test'), |
| 144 return unittest.TestSuite(l) | 186 return unittest.TestSuite(l) |
| 145 | 187 |
| 146 | 188 |
| 147 # | 189 # |
| 148 # $Log: not supported by cvs2svn $ | 190 # $Log: not supported by cvs2svn $ |
| 191 # Revision 1.1 2002/01/02 02:31:38 richard | |
| 192 # Sorry for the huge checkin message - I was only intending to implement #496356 | |
| 193 # but I found a number of places where things had been broken by transactions: | |
| 194 # . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename | |
| 195 # for _all_ roundup-generated smtp messages to be sent to. | |
| 196 # . the transaction cache had broken the roundupdb.Class set() reactors | |
| 197 # . newly-created author users in the mailgw weren't being committed to the db | |
| 198 # | |
| 199 # Stuff that made it into CHANGES.txt (ie. the stuff I was actually working | |
| 200 # on when I found that stuff :): | |
| 201 # . #496356 ] Use threading in messages | |
| 202 # . detectors were being registered multiple times | |
| 203 # . added tests for mailgw | |
| 204 # . much better attaching of erroneous messages in the mail gateway | |
| 205 # | |
| 149 # | 206 # |
| 150 # | 207 # |
| 151 # | 208 # |
| 152 # vim: set filetype=python ts=4 sw=4 et si | 209 # vim: set filetype=python ts=4 sw=4 et si |
