1 # $Id: test_memorydb.py,v 1.4 2004-11-03 01:34:21 richard Exp $
3 import unittest, os, shutil, time
5 from roundup import hyperdb
7 from db_test_base import DBTest, ROTest, SchemaTest, config, setupSchema
8 import memorydb
10 class memorydbOpener:
11 module = memorydb
13 def nuke_database(self):
14 # really kill it
15 self.db = None
17 db = None
18 def open_database(self):
19 if self.db is None:
20 self.db = self.module.Database(config, 'admin')
21 return self.db
23 def setUp(self):
24 self.open_database()
25 setupSchema(self.db, 1, self.module)
27 def tearDown(self):
28 if self.db is not None:
29 self.db.close()
31 # nuke and re-create db for restore
32 def nukeAndCreate(self):
33 self.db.close()
34 self.nuke_database()
35 self.db = self.module.Database(config, 'admin')
36 setupSchema(self.db, 0, self.module)
38 class memorydbDBTest(memorydbOpener, DBTest):
39 pass
41 class memorydbROTest(memorydbOpener, ROTest):
42 def setUp(self):
43 self.db = self.module.Database(config)
44 setupSchema(self.db, 0, self.module)
46 class memorydbSchemaTest(memorydbOpener, SchemaTest):
47 pass
49 from session_common import DBMTest
50 class memorydbSessionTest(memorydbOpener, DBMTest):
51 def setUp(self):
52 self.db = self.module.Database(config, 'admin')
53 setupSchema(self.db, 1, self.module)
54 self.sessions = self.db.sessions
56 def test_suite():
57 suite = unittest.TestSuite()
58 print 'Including memorydb tests'
59 suite.addTest(unittest.makeSuite(memorydbDBTest))
60 suite.addTest(unittest.makeSuite(memorydbROTest))
61 suite.addTest(unittest.makeSuite(memorydbSchemaTest))
62 suite.addTest(unittest.makeSuite(memorydbSessionTest))
63 return suite
65 if __name__ == '__main__':
66 runner = unittest.TextTestRunner()
67 unittest.main(testRunner=runner)
70 # vim: set filetype=python ts=4 sw=4 et si