1 # $Id: test_init.py,v 1.2 2001-08-05 07:45:27 richard Exp $
3 import unittest, os, shutil, errno, imp, sys
5 from roundup.init import init
7 class MyTestCase(unittest.TestCase):
8 count = 0
9 def setUp(self):
10 MyTestCase.count = MyTestCase.count + 1
11 self.dirname = '_test_%s'%self.count
12 try:
13 shutil.rmtree(self.dirname)
14 except OSError, error:
15 if error.errno != errno.ENOENT: raise
17 def tearDown(self):
18 try:
19 shutil.rmtree(self.dirname)
20 except OSError, error:
21 if error.errno != errno.ENOENT: raise
23 class ClassicTestCase(MyTestCase):
24 backend = 'anydbm'
25 def testCreation(self):
26 ae = self.assertEqual
28 # create the instance
29 init(self.dirname, 'classic', self.backend, 'sekrit')
31 # check we can load the package
32 instance = imp.load_package(self.dirname, self.dirname)
34 # and open the database
35 db = instance.open()
37 # check the basics of the schema and initial data set
38 l = db.priority.list()
39 ae(l, ['1', '2', '3', '4', '5'])
40 l = db.status.list()
41 ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
42 l = db.keyword.list()
43 ae(l, [])
44 l = db.user.list()
45 ae(l, ['1'])
46 l = db.msg.list()
47 ae(l, [])
48 l = db.file.list()
49 ae(l, [])
50 l = db.issue.list()
51 ae(l, [])
53 class ExtendedTestCase(MyTestCase):
54 backend = 'anydbm'
55 def testCreation(self):
56 ae = self.assertEqual
58 # create the instance
59 init(self.dirname, 'extended', self.backend, 'sekrit')
61 # check we can load the package
62 instance = imp.load_package(self.dirname, self.dirname)
64 # and open the database
65 db = instance.open()
67 # check the basics of the schema and initial data set
68 l = db.priority.list()
69 ae(l, ['1', '2', '3', '4'])
70 l = db.status.list()
71 ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
72 l = db.keyword.list()
73 ae(l, [])
74 l = db.user.list()
75 ae(l, ['1'])
76 l = db.msg.list()
77 ae(l, [])
78 l = db.file.list()
79 ae(l, [])
80 l = db.issue.list()
81 ae(l, [])
82 l = db.support.list()
83 ae(l, [])
84 l = db.rate.list()
85 ae(l, ['1', '2', '3'])
86 l = db.source.list()
87 ae(l, ['1', '2', '3', '4'])
88 l = db.platform.list()
89 ae(l, ['1', '2', '3'])
90 l = db.timelog.list()
91 ae(l, [])
93 def suite():
94 l = [unittest.makeSuite(ClassicTestCase, 'test'),
95 unittest.makeSuite(ExtendedTestCase, 'test')]
96 try:
97 import bsddb
98 x = ClassicTestCase
99 x.backend = 'bsddb'
100 l.append(unittest.makeSuite(x, 'test'))
101 x = ExtendedTestCase
102 x.backend = 'bsddb'
103 l.append(unittest.makeSuite(x, 'test'))
104 except:
105 print 'bsddb module not found, skipping bsddb DBTestCase'
107 try:
108 import bsddb3
109 x = ClassicTestCase
110 x.backend = 'bsddb3'
111 l.append(unittest.makeSuite(x, 'test'))
112 x = ExtendedTestCase
113 x.backend = 'bsddb3'
114 l.append(unittest.makeSuite(x, 'test'))
115 except:
116 print 'bsddb3 module not found, skipping bsddb3 DBTestCase'
118 return unittest.TestSuite(l)
120 #
121 # $Log: not supported by cvs2svn $
122 # Revision 1.1 2001/08/05 07:07:58 richard
123 # added tests for roundup.init - but they're disabled until I can figure _if_
124 # we can run them (import problems).
125 #
126 #
127 #
128 # vim: set filetype=python ts=4 sw=4 et si