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.21 2003-02-28 03:33:25 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')
47 init.write_select_db(self.dirname, self.backend)
48 init.initialise(self.dirname, 'sekrit')
50 # check we can load the package
51 instance = imp.load_package(self.dirname, self.dirname)
53 # and open the database
54 db = instance.open()
56 # check the basics of the schema and initial data set
57 l = db.priority.list()
58 ae(l, ['1', '2', '3', '4', '5'])
59 l = db.status.list()
60 ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
61 l = db.keyword.list()
62 ae(l, [])
63 l = db.user.list()
64 ae(l, ['1', '2'])
65 l = db.msg.list()
66 ae(l, [])
67 l = db.file.list()
68 ae(l, [])
69 l = db.issue.list()
70 ae(l, [])
72 class bsddbClassicTestCase(ClassicTestCase):
73 backend = 'bsddb'
75 class bsddb3ClassicTestCase(ClassicTestCase):
76 backend = 'bsddb3'
78 class metakitClassicTestCase(ClassicTestCase):
79 backend = 'metakit'
81 class gadflyClassicTestCase(ClassicTestCase):
82 backend = 'gadfly'
84 class sqliteClassicTestCase(ClassicTestCase):
85 backend = 'sqlite'
87 def suite():
88 l = [
89 unittest.makeSuite(ClassicTestCase, 'test'),
90 ]
92 from roundup import backends
93 if hasattr(backends, 'bsddb'):
94 l.append(unittest.makeSuite(bsddbClassicTestCase, 'test'))
95 if hasattr(backends, 'bsddb3'):
96 l.append(unittest.makeSuite(bsddb3ClassicTestCase, 'test'))
97 if hasattr(backends, 'metakit'):
98 l.append(unittest.makeSuite(metakitClassicTestCase, 'test'))
99 if hasattr(backends, 'gadfly'):
100 l.append(unittest.makeSuite(gadflyClassicTestCase, 'test'))
101 if hasattr(backends, 'sqlite'):
102 l.append(unittest.makeSuite(sqliteClassicTestCase, 'test'))
104 return unittest.TestSuite(l)
106 # vim: set filetype=python ts=4 sw=4 et si