1 # $Id: test_init.py,v 1.1 2001-08-05 07:07:58 richard Exp $
3 import unittest, os, shutil, errno, imp, sys
5 from roundup.init import init
7 class MyTestCase(unittest.TestCase):
8 def tearDown(self):
9 try:
10 shutil.rmtree('_test_dir')
11 except OSError, error:
12 if error.errno == errno.ENOENT: raise
14 class ClassicTestCase(MyTestCase):
15 backend = 'anydbm'
16 def testCreation(self):
17 ae = self.assertEqual
19 # create the instance
20 init('_test_dir', 'classic', self.backend, 'sekrit')
22 # check we can load the package
23 instance = imp.load_package('_test_dir', '_test_dir')
25 # and open the database
26 db = instance.open()
28 # check the basics of the schema and initial data set
29 l = db.priority.list()
30 ae(l, ['1', '2', '3', '4', '5'])
31 l = db.status.list()
32 ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
33 l = db.keyword.list()
34 ae(l, [])
35 l = db.user.list()
36 ae(l, ['1'])
37 l = db.msg.list()
38 ae(l, [])
39 l = db.file.list()
40 ae(l, [])
41 l = db.issue.list()
42 ae(l, [])
44 class ExtendedTestCase(MyTestCase):
45 backend = 'anydbm'
46 def testCreation(self):
47 ae = self.assertEqual
49 # create the instance
50 init('_test_dir', 'extended', self.backend, 'sekrit')
52 # check we can load the package
53 del sys.modules['_test_dir']
54 instance = imp.load_package('_test_dir', '_test_dir')
56 # and open the database
57 db = instance.open()
59 # check the basics of the schema and initial data set
60 l = db.priority.list()
61 ae(l, ['1', '2', '3', '4', '5'])
62 l = db.status.list()
63 ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
64 l = db.keyword.list()
65 ae(l, [])
66 l = db.user.list()
67 ae(l, ['1'])
68 l = db.msg.list()
69 ae(l, [])
70 l = db.file.list()
71 ae(l, [])
72 l = db.issue.list()
73 ae(l, [])
74 l = db.support.list()
75 ae(l, [])
76 l = db.rate.list()
77 ae(l, ['1', '2', '3'])
78 l = db.source.list()
79 ae(l, ['1', '2', '3', '4'])
80 l = db.platform.list()
81 ae(l, ['1', '2', '3'])
82 l = db.timelog.list()
83 ae(l, [])
85 def suite():
86 l = [unittest.makeSuite(ClassicTestCase, 'test'),
87 unittest.makeSuite(ExtendedTestCase, 'test')]
88 try:
89 import bsddb
90 x = ClassicTestCase
91 x.backend = 'bsddb'
92 l.append(unittest.makeSuite(x, 'test'))
93 x = ExtendedTestCase
94 x.backend = 'bsddb'
95 l.append(unittest.makeSuite(x, 'test'))
96 except:
97 print 'bsddb module not found, skipping bsddb DBTestCase'
99 try:
100 import bsddb3
101 x = ClassicTestCase
102 x.backend = 'bsddb3'
103 l.append(unittest.makeSuite(x, 'test'))
104 x = ExtendedTestCase
105 x.backend = 'bsddb3'
106 l.append(unittest.makeSuite(x, 'test'))
107 except:
108 print 'bsddb3 module not found, skipping bsddb3 DBTestCase'
110 return unittest.TestSuite(l)
112 #
113 # $Log: not supported by cvs2svn $
114 #
115 #
116 # vim: set filetype=python ts=4 sw=4 et si