Code

removed Log
[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.16 2002-09-10 00:19:54 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', '2'])
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', '2'])
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 = [
129         unittest.makeSuite(ClassicTestCase, 'test'),
130         unittest.makeSuite(ExtendedTestCase, 'test')
131     ]
133     try:
134         import bsddb
135         l.append(unittest.makeSuite(bsddbClassicTestCase, 'test'))
136         l.append(unittest.makeSuite(bsddbExtendedTestCase, 'test'))
137     except:
138         print 'bsddb module not found, skipping bsddb DBTestCase'
140     try:
141         import bsddb3
142         l.append(unittest.makeSuite(bsddb3ClassicTestCase, 'test'))
143         l.append(unittest.makeSuite(bsddb3ExtendedTestCase, 'test'))
144     except:
145         print 'bsddb3 module not found, skipping bsddb3 DBTestCase'
147     try:
148         import metakit
149         l.append(unittest.makeSuite(metakitClassicTestCase, 'test'))
150         l.append(unittest.makeSuite(metakitExtendedTestCase, 'test'))
151     except:
152         print 'metakit module not found, skipping metakit DBTestCase'
154     return unittest.TestSuite(l)
156 # vim: set filetype=python ts=4 sw=4 et si