e2383cb6b03186313a4f35e1be4ddb97bc33d88b
1 #
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
3 # This module is free software, and you may redistribute it and/or modify
4 # under the same terms as Python, so long as this copyright message and
5 # disclaimer are retained in their original form.
6 #
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
10 # POSSIBILITY OF SUCH DAMAGE.
11 #
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 #
18 # $Id: test_init.py,v 1.6 2001-09-29 23:48:06 richard Exp $
20 import unittest, os, shutil, errno, imp, sys
22 from roundup.init import init
24 class MyTestCase(unittest.TestCase):
25 count = 0
26 def setUp(self):
27 MyTestCase.count = MyTestCase.count + 1
28 self.dirname = '_test_%s'%self.count
29 try:
30 shutil.rmtree(self.dirname)
31 except OSError, error:
32 if error.errno != errno.ENOENT: raise
33 except WindowsError, error:
34 if error.errno != 3: raise
36 def tearDown(self):
37 try:
38 shutil.rmtree(self.dirname)
39 except OSError, error:
40 if error.errno != errno.ENOENT: raise
41 except WindowsError, error:
42 if error.errno != 3: raise
44 class ClassicTestCase(MyTestCase):
45 backend = 'anydbm'
46 def testCreation(self):
47 ae = self.assertEqual
49 # create the instance
50 init(self.dirname, 'classic', self.backend, 'sekrit')
52 # check we can load the package
53 instance = imp.load_package(self.dirname, self.dirname)
55 # and open the database
56 db = instance.open()
58 # check the basics of the schema and initial data set
59 l = db.priority.list()
60 ae(l, ['1', '2', '3', '4', '5'])
61 l = db.status.list()
62 ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
63 l = db.keyword.list()
64 ae(l, [])
65 l = db.user.list()
66 ae(l, ['1'])
67 l = db.msg.list()
68 ae(l, [])
69 l = db.file.list()
70 ae(l, [])
71 l = db.issue.list()
72 ae(l, [])
74 class ExtendedTestCase(MyTestCase):
75 backend = 'anydbm'
76 def testCreation(self):
77 ae = self.assertEqual
79 # create the instance
80 init(self.dirname, 'extended', self.backend, 'sekrit')
82 # check we can load the package
83 instance = imp.load_package(self.dirname, self.dirname)
85 # and open the database
86 db = instance.open()
88 # check the basics of the schema and initial data set
89 l = db.priority.list()
90 ae(l, ['1', '2', '3', '4'])
91 l = db.status.list()
92 ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
93 l = db.keyword.list()
94 ae(l, [])
95 l = db.user.list()
96 ae(l, ['1'])
97 l = db.msg.list()
98 ae(l, [])
99 l = db.file.list()
100 ae(l, [])
101 l = db.issue.list()
102 ae(l, [])
103 l = db.support.list()
104 ae(l, [])
105 l = db.rate.list()
106 ae(l, ['1', '2', '3'])
107 l = db.source.list()
108 ae(l, ['1', '2', '3', '4'])
109 l = db.platform.list()
110 ae(l, ['1', '2', '3'])
111 l = db.timelog.list()
112 ae(l, [])
114 def suite():
115 l = [unittest.makeSuite(ClassicTestCase, 'test'),
116 unittest.makeSuite(ExtendedTestCase, 'test')]
117 try:
118 import bsddb
119 x = ClassicTestCase
120 x.backend = 'bsddb'
121 l.append(unittest.makeSuite(x, 'test'))
122 x = ExtendedTestCase
123 x.backend = 'bsddb'
124 l.append(unittest.makeSuite(x, 'test'))
125 except:
126 print 'bsddb module not found, skipping bsddb DBTestCase'
128 # try:
129 # import bsddb3
130 # x = ClassicTestCase
131 # x.backend = 'bsddb3'
132 # l.append(unittest.makeSuite(x, 'test'))
133 # x = ExtendedTestCase
134 # x.backend = 'bsddb3'
135 # l.append(unittest.makeSuite(x, 'test'))
136 # except:
137 # print 'bsddb3 module not found, skipping bsddb3 DBTestCase'
139 return unittest.TestSuite(l)
141 #
142 # $Log: not supported by cvs2svn $
143 # Revision 1.5 2001/08/29 06:23:59 richard
144 # Disabled the bsddb3 module entirely in the unit testing. See CHANGES for
145 # details.
146 #
147 # Revision 1.4 2001/08/07 00:24:43 richard
148 # stupid typo
149 #
150 # Revision 1.3 2001/08/07 00:15:51 richard
151 # Added the copyright/license notice to (nearly) all files at request of
152 # Bizar Software.
153 #
154 # Revision 1.2 2001/08/05 07:45:27 richard
155 # Added tests for instance initialisation
156 #
157 # Revision 1.1 2001/08/05 07:07:58 richard
158 # added tests for roundup.init - but they're disabled until I can figure _if_
159 # we can run them (import problems).
160 #
161 #
162 #
163 # vim: set filetype=python ts=4 sw=4 et si