Skip to content

Commit 17fd2f6

Browse files
author
Richard Jones
committed
added tests for roundup.init
but they're disabled until I can figure _if_ we can run them (import problems).
1 parent db9756d commit 17fd2f6

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

test/test_init.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# $Id: test_init.py,v 1.1 2001-08-05 07:07:58 richard Exp $
2+
3+
import unittest, os, shutil, errno, imp, sys
4+
5+
from roundup.init import init
6+
7+
class MyTestCase(unittest.TestCase):
8+
def tearDown(self):
9+
try:
10+
shutil.rmtree('_test_dir')
11+
except OSError, error:
12+
if error.errno == errno.ENOENT: raise
13+
14+
class ClassicTestCase(MyTestCase):
15+
backend = 'anydbm'
16+
def testCreation(self):
17+
ae = self.assertEqual
18+
19+
# create the instance
20+
init('_test_dir', 'classic', self.backend, 'sekrit')
21+
22+
# check we can load the package
23+
instance = imp.load_package('_test_dir', '_test_dir')
24+
25+
# and open the database
26+
db = instance.open()
27+
28+
# check the basics of the schema and initial data set
29+
l = db.priority.list()
30+
ae(l, ['1', '2', '3', '4', '5'])
31+
l = db.status.list()
32+
ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
33+
l = db.keyword.list()
34+
ae(l, [])
35+
l = db.user.list()
36+
ae(l, ['1'])
37+
l = db.msg.list()
38+
ae(l, [])
39+
l = db.file.list()
40+
ae(l, [])
41+
l = db.issue.list()
42+
ae(l, [])
43+
44+
class ExtendedTestCase(MyTestCase):
45+
backend = 'anydbm'
46+
def testCreation(self):
47+
ae = self.assertEqual
48+
49+
# create the instance
50+
init('_test_dir', 'extended', self.backend, 'sekrit')
51+
52+
# check we can load the package
53+
del sys.modules['_test_dir']
54+
instance = imp.load_package('_test_dir', '_test_dir')
55+
56+
# and open the database
57+
db = instance.open()
58+
59+
# check the basics of the schema and initial data set
60+
l = db.priority.list()
61+
ae(l, ['1', '2', '3', '4', '5'])
62+
l = db.status.list()
63+
ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
64+
l = db.keyword.list()
65+
ae(l, [])
66+
l = db.user.list()
67+
ae(l, ['1'])
68+
l = db.msg.list()
69+
ae(l, [])
70+
l = db.file.list()
71+
ae(l, [])
72+
l = db.issue.list()
73+
ae(l, [])
74+
l = db.support.list()
75+
ae(l, [])
76+
l = db.rate.list()
77+
ae(l, ['1', '2', '3'])
78+
l = db.source.list()
79+
ae(l, ['1', '2', '3', '4'])
80+
l = db.platform.list()
81+
ae(l, ['1', '2', '3'])
82+
l = db.timelog.list()
83+
ae(l, [])
84+
85+
def suite():
86+
l = [unittest.makeSuite(ClassicTestCase, 'test'),
87+
unittest.makeSuite(ExtendedTestCase, 'test')]
88+
try:
89+
import bsddb
90+
x = ClassicTestCase
91+
x.backend = 'bsddb'
92+
l.append(unittest.makeSuite(x, 'test'))
93+
x = ExtendedTestCase
94+
x.backend = 'bsddb'
95+
l.append(unittest.makeSuite(x, 'test'))
96+
except:
97+
print 'bsddb module not found, skipping bsddb DBTestCase'
98+
99+
try:
100+
import bsddb3
101+
x = ClassicTestCase
102+
x.backend = 'bsddb3'
103+
l.append(unittest.makeSuite(x, 'test'))
104+
x = ExtendedTestCase
105+
x.backend = 'bsddb3'
106+
l.append(unittest.makeSuite(x, 'test'))
107+
except:
108+
print 'bsddb3 module not found, skipping bsddb3 DBTestCase'
109+
110+
return unittest.TestSuite(l)
111+
112+
#
113+
# $Log: not supported by cvs2svn $
114+
#
115+
#
116+
# vim: set filetype=python ts=4 sw=4 et si

0 commit comments

Comments
 (0)