Premiere version : mise en route du suivi.
[auf_roundup.git] / test / test_memorydb.py
1 # $Id: test_memorydb.py,v 1.4 2004-11-03 01:34:21 richard Exp $
2
3 import unittest, os, shutil, time
4
5 from roundup import hyperdb
6
7 from db_test_base import DBTest, ROTest, SchemaTest, config, setupSchema
8 import memorydb
9
10 class memorydbOpener:
11 module = memorydb
12
13 def nuke_database(self):
14 # really kill it
15 self.db = None
16
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
22
23 def setUp(self):
24 self.open_database()
25 setupSchema(self.db, 1, self.module)
26
27 def tearDown(self):
28 if self.db is not None:
29 self.db.close()
30
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)
37
38 class memorydbDBTest(memorydbOpener, DBTest):
39 pass
40
41 class memorydbROTest(memorydbOpener, ROTest):
42 def setUp(self):
43 self.db = self.module.Database(config)
44 setupSchema(self.db, 0, self.module)
45
46 class memorydbSchemaTest(memorydbOpener, SchemaTest):
47 pass
48
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
55
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
64
65 if __name__ == '__main__':
66 runner = unittest.TextTestRunner()
67 unittest.main(testRunner=runner)
68
69
70 # vim: set filetype=python ts=4 sw=4 et si
71