Code

On second thought, that last checkin was dumb.
[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.19 2002-09-18 05:07:49 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 bsddbClassicTestCase(ClassicTestCase):
72     backend = 'bsddb'
74 class bsddb3ClassicTestCase(ClassicTestCase):
75     backend = 'bsddb3'
77 class metakitClassicTestCase(ClassicTestCase):
78     backend = 'metakit'
80 class gadflyClassicTestCase(ClassicTestCase):
81     backend = 'gadfly'
83 class sqliteClassicTestCase(ClassicTestCase):
84     backend = 'sqlite'
86 def suite():
87     l = [
88         unittest.makeSuite(ClassicTestCase, 'test'),
89     ]
91     try:
92         import bsddb
93         l.append(unittest.makeSuite(bsddbClassicTestCase, 'test'))
94     except:
95         print 'bsddb module not found, skipping bsddb init test'
97     try:
98         import bsddb3
99         l.append(unittest.makeSuite(bsddb3ClassicTestCase, 'test'))
100     except:
101         print 'bsddb3 module not found, skipping bsddb3 init test'
103     try:
104         import metakit
105         l.append(unittest.makeSuite(metakitClassicTestCase, 'test'))
106     except:
107         print 'metakit module not found, skipping metakit init test'
109     try:
110         import gadfly
111         l.append(unittest.makeSuite(gadflyClassicTestCase, 'test'))
112     except:
113         print 'gadfly module not found, skipping gadfly init test'
115     try:
116         import sqlite
117         l.append(unittest.makeSuite(sqliteClassicTestCase, 'test'))
118     except:
119         print 'sqlite module not found, skipping sqlite init test'
121     return unittest.TestSuite(l)
123 # vim: set filetype=python ts=4 sw=4 et si