Skip to content

Commit 0da8b3e

Browse files
author
Richard Jones
committed
don't have mailgw tests close the db - they're not testing persistence
1 parent 05da614 commit 0da8b3e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

test/db_test_base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,9 @@ def setUp(self):
18631863
shutil.rmtree(config.DATABASE)
18641864
os.makedirs(config.DATABASE + '/files')
18651865

1866+
def open_database(self):
1867+
self.db = self.module.Database(config, 'admin')
1868+
18661869
def test_reservedProperties(self):
18671870
self.open_database()
18681871
self.assertRaises(ValueError, self.module.Class, self.db, "a",

test/memorydb.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ def __init__(self, config, journaltag=None):
184184
self.sessions = Sessions()
185185
self.otks = OneTimeKeys()
186186
self.indexer = Indexer(self)
187-
self.sessions = Sessions()
188187

189188
# anydbm bits
190189
self.cache = {} # cache of nodes loaded or created
@@ -193,7 +192,6 @@ def __init__(self, config, journaltag=None):
193192
self.destroyednodes = {}# keep track of the destroyed nodes by class
194193
self.transactions = []
195194

196-
197195
def filename(self, classname, nodeid, property=None, create=0):
198196
shutil.copyfile(__file__, __file__+'.dummy')
199197
return __file__+'.dummy'

test/test_mailgw.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,16 @@ def tearDown(self):
143143
os.remove(SENDMAILDEBUG)
144144
self.db.close()
145145

146+
def _create_mailgw(self, message):
147+
class MailGW(self.instance.MailGW):
148+
def handle_message(self, message):
149+
return self._handle_message(message)
150+
handler = MailGW(self.instance)
151+
handler.db = self.db
152+
return handler
153+
146154
def _handle_mail(self, message):
147-
handler = self.instance.MailGW(self.instance)
155+
handler = self._create_mailgw(message)
148156
handler.trapExceptions = 0
149157
return handler.main(StringIO(message))
150158

@@ -582,7 +590,7 @@ def testPropertyChangeOnly(self):
582590
# reconstruct old behaviour: This would reuse the
583591
# database-handle from the doNewIssue above which has committed
584592
# as user "Chef". So we close and reopen the db as that user.
585-
self.db.close()
593+
#self.db.close() actually don't close 'cos this empties memorydb
586594
self.db = self.instance.open('Chef')
587595
self.db.issue.set('1', assignedto=self.chef_id)
588596
self.db.commit()
@@ -1032,6 +1040,7 @@ def testNosyRemove(self):
10321040
assert not os.path.exists(SENDMAILDEBUG)
10331041

10341042
def testNewUserAuthor(self):
1043+
self.db.commit()
10351044
l = self.db.user.list()
10361045
l.sort()
10371046
message = '''Content-Type: text/plain;
@@ -1133,8 +1142,7 @@ def testUnknownUser(self):
11331142
11341143
This is a test submission of a new issue.
11351144
'''
1136-
self.db.close()
1137-
handler = self.instance.MailGW(self.instance)
1145+
handler = self._create_mailgw(message)
11381146
# we want a bounce message:
11391147
handler.trapExceptions = 1
11401148
ret = handler.main(StringIO(message))

0 commit comments

Comments
 (0)