From: richard Date: Mon, 8 Feb 2010 08:30:37 +0000 (+0000) Subject: don't have mailgw tests close the db - they're not testing persistence X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f8d3a138e9bc41a3fc4e30f496f4efb12544fa42;p=roundup.git don't have mailgw tests close the db - they're not testing persistence git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4454 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/test/db_test_base.py b/test/db_test_base.py index 7fd2663..bb4272a 100644 --- a/test/db_test_base.py +++ b/test/db_test_base.py @@ -1863,6 +1863,9 @@ class SchemaTest(MyTestCase): shutil.rmtree(config.DATABASE) os.makedirs(config.DATABASE + '/files') + def open_database(self): + self.db = self.module.Database(config, 'admin') + def test_reservedProperties(self): self.open_database() self.assertRaises(ValueError, self.module.Class, self.db, "a", diff --git a/test/memorydb.py b/test/memorydb.py index 9565050..17c8330 100644 --- a/test/memorydb.py +++ b/test/memorydb.py @@ -184,7 +184,6 @@ class Database(back_anydbm.Database): self.sessions = Sessions() self.otks = OneTimeKeys() self.indexer = Indexer(self) - self.sessions = Sessions() # anydbm bits self.cache = {} # cache of nodes loaded or created @@ -193,7 +192,6 @@ class Database(back_anydbm.Database): self.destroyednodes = {}# keep track of the destroyed nodes by class self.transactions = [] - def filename(self, classname, nodeid, property=None, create=0): shutil.copyfile(__file__, __file__+'.dummy') return __file__+'.dummy' diff --git a/test/test_mailgw.py b/test/test_mailgw.py index ca3419f..b1e4db9 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -143,8 +143,16 @@ class MailgwTestCase(unittest.TestCase, DiffHelper): os.remove(SENDMAILDEBUG) self.db.close() + def _create_mailgw(self, message): + class MailGW(self.instance.MailGW): + def handle_message(self, message): + return self._handle_message(message) + handler = MailGW(self.instance) + handler.db = self.db + return handler + def _handle_mail(self, message): - handler = self.instance.MailGW(self.instance) + handler = self._create_mailgw(message) handler.trapExceptions = 0 return handler.main(StringIO(message)) @@ -582,7 +590,7 @@ _______________________________________________________________________ # reconstruct old behaviour: This would reuse the # database-handle from the doNewIssue above which has committed # as user "Chef". So we close and reopen the db as that user. - self.db.close() + #self.db.close() actually don't close 'cos this empties memorydb self.db = self.instance.open('Chef') self.db.issue.set('1', assignedto=self.chef_id) self.db.commit() @@ -1032,6 +1040,7 @@ Subject: [issue1] Testing... [nosy=-richard] assert not os.path.exists(SENDMAILDEBUG) def testNewUserAuthor(self): + self.db.commit() l = self.db.user.list() l.sort() message = '''Content-Type: text/plain; @@ -1133,8 +1142,7 @@ Subject: [issue] Testing nonexisting user... This is a test submission of a new issue. ''' - self.db.close() - handler = self.instance.MailGW(self.instance) + handler = self._create_mailgw(message) # we want a bounce message: handler.trapExceptions = 1 ret = handler.main(StringIO(message))