Code

Forgot to add to init tests
[roundup.git] / test / test_init.py
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.11 2002-07-11 01:12:34 richard Exp $
20 import unittest, os, shutil, errno, imp, sys
22 from roundup import init
24 class MyTestCase(unittest.TestCase):
25     count = 0
26     def setUp(self):
27         MyTestCase.count = MyTestCase.count + 1
28         self.dirname = '_test_init_%s'%self.count
29         try:
30             shutil.rmtree(self.dirname)
31         except OSError, error:
32             if error.errno not in (errno.ENOENT, errno.ESRCH): raise
34     def tearDown(self):
35         try:
36             shutil.rmtree(self.dirname)
37         except OSError, error:
38             if error.errno not in (errno.ENOENT, errno.ESRCH): raise
40 class ClassicTestCase(MyTestCase):
41     backend = 'anydbm'
42     def testCreation(self):
43         ae = self.assertEqual
45         # create the instance
46         init.install(self.dirname, 'classic', self.backend)
47         init.initialise(self.dirname, 'sekrit')
49         # check we can load the package
50         instance = imp.load_package(self.dirname, self.dirname)
52         # and open the database
53         db = instance.open()
55         # check the basics of the schema and initial data set
56         l = db.priority.list()
57         ae(l, ['1', '2', '3', '4', '5'])
58         l = db.status.list()
59         ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
60         l = db.keyword.list()
61         ae(l, [])
62         l = db.user.list()
63         ae(l, ['1'])
64         l = db.msg.list()
65         ae(l, [])
66         l = db.file.list()
67         ae(l, [])
68         l = db.issue.list()
69         ae(l, [])
71 class ExtendedTestCase(MyTestCase):
72     backend = 'anydbm'
73     def testCreation(self):
74         ae = self.assertEqual
76         # create the instance
77         init.install(self.dirname, 'extended', self.backend)
78         init.initialise(self.dirname, 'sekrit')
80         # check we can load the package
81         instance = imp.load_package(self.dirname, self.dirname)
83         # and open the database
84         db = instance.open()
86         # check the basics of the schema and initial data set
87         l = db.priority.list()
88         ae(l, ['1', '2', '3', '4'])
89         l = db.status.list()
90         ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
91         l = db.keyword.list()
92         ae(l, [])
93         l = db.user.list()
94         ae(l, ['1'])
95         l = db.msg.list()
96         ae(l, [])
97         l = db.file.list()
98         ae(l, [])
99         l = db.issue.list()
100         ae(l, [])
101         l = db.support.list()
102         ae(l, [])
103         l = db.rate.list()
104         ae(l, ['1', '2', '3'])
105         l = db.source.list()
106         ae(l, ['1', '2', '3', '4'])
107         l = db.platform.list()
108         ae(l, ['1', '2', '3'])
109         l = db.timelog.list()
110         ae(l, [])
112 class bsddbClassicTestCase(ClassicTestCase):
113     backend = 'bsddb'
114 class bsddbExtendedTestCase(ExtendedTestCase):
115     backend = 'bsddb'
117 class bsddb3ClassicTestCase(ClassicTestCase):
118     backend = 'bsddb3'
119 class bsddb3ExtendedTestCase(ExtendedTestCase):
120     backend = 'bsddb3'
122 class metakitClassicTestCase(ClassicTestCase):
123     backend = 'metakit'
124 class metakitExtendedTestCase(ExtendedTestCase):
125     backend = 'metakit'
127 def suite():
128     l = [unittest.makeSuite(ClassicTestCase, 'test'),
129          unittest.makeSuite(ExtendedTestCase, 'test')]
130     try:
131         import bsddb
132         l.append(unittest.makeSuite(bsddbClassicTestCase, 'test'))
133         l.append(unittest.makeSuite(bsddbExtendedTestCase, 'test'))
134     except:
135         print 'bsddb module not found, skipping bsddb DBTestCase'
137     try:
138         import bsddb3
139         l.append(unittest.makeSuite(bsddb3ClassicTestCase, 'test'))
140         l.append(unittest.makeSuite(bsddb3ExtendedTestCase, 'test'))
141     except:
142         print 'bsddb3 module not found, skipping bsddb3 DBTestCase'
144     try:
145         import metakit
146         l.append(unittest.makeSuite(metakitClassicTestCase, 'test'))
147         l.append(unittest.makeSuite(metakitExtendedTestCase, 'test'))
148     except:
149         print 'metakit module not found, skipping bsddb3 DBTestCase'
151     return unittest.TestSuite(l)
154 # $Log: not supported by cvs2svn $
155 # Revision 1.10  2002/06/11 04:59:14  richard
156 # enabled testing of bsddb in test_init
158 # Revision 1.9  2002/05/23 04:26:05  richard
159 # 'I must run unit tests before committing\n' * 100
161 # Revision 1.8  2002/05/15 03:27:16  richard
162 #  . fixed SCRIPT_NAME in ZRoundup for instances not at top level of Zope
163 #    (thanks dman)
164 #  . fixed some sorting issues that were breaking some unit tests under py2.2
165 #  . mailgw test output dir was confusing the init test (but only on 2.2 *shrug*)
167 # fixed bug in the init unit test that meant only the bsddb test ran if it
168 # could (it clobbered the anydbm test)
170 # Revision 1.7  2001/10/28 22:51:38  richard
171 # Fixed ENOENT/WindowsError thing, thanks Juergen Hermann
173 # Revision 1.6  2001/09/29 23:48:06  richard
174 # Bug fix for test_init on Windows.
175 # More documenation!!
177 # Revision 1.5  2001/08/29 06:23:59  richard
178 # Disabled the bsddb3 module entirely in the unit testing. See CHANGES for
179 # details.
181 # Revision 1.4  2001/08/07 00:24:43  richard
182 # stupid typo
184 # Revision 1.3  2001/08/07 00:15:51  richard
185 # Added the copyright/license notice to (nearly) all files at request of
186 # Bizar Software.
188 # Revision 1.2  2001/08/05 07:45:27  richard
189 # Added tests for instance initialisation
191 # Revision 1.1  2001/08/05 07:07:58  richard
192 # added tests for roundup.init - but they're disabled until I can figure _if_
193 # we can run them (import problems).
197 # vim: set filetype=python ts=4 sw=4 et si