[go: up one dir, main page]

Menu

[82a575]: / test / test_init.py  Maximize  Restore  History

Download this file

164 lines (145 with data), 5.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#
# Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
# This module is free software, and you may redistribute it and/or modify
# under the same terms as Python, so long as this copyright message and
# disclaimer are retained in their original form.
#
# IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
# OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
# $Id: test_init.py,v 1.7 2001-10-28 22:51:38 richard Exp $
import unittest, os, shutil, errno, imp, sys
from roundup.init import init
class MyTestCase(unittest.TestCase):
count = 0
def setUp(self):
MyTestCase.count = MyTestCase.count + 1
self.dirname = '_test_%s'%self.count
try:
shutil.rmtree(self.dirname)
except OSError, error:
if error.errno not in (errno.ENOENT, errno.ESRCH): raise
def tearDown(self):
try:
shutil.rmtree(self.dirname)
except OSError, error:
if error.errno not in (errno.ENOENT, errno.ESRCH): raise
class ClassicTestCase(MyTestCase):
backend = 'anydbm'
def testCreation(self):
ae = self.assertEqual
# create the instance
init(self.dirname, 'classic', self.backend, 'sekrit')
# check we can load the package
instance = imp.load_package(self.dirname, self.dirname)
# and open the database
db = instance.open()
# check the basics of the schema and initial data set
l = db.priority.list()
ae(l, ['1', '2', '3', '4', '5'])
l = db.status.list()
ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
l = db.keyword.list()
ae(l, [])
l = db.user.list()
ae(l, ['1'])
l = db.msg.list()
ae(l, [])
l = db.file.list()
ae(l, [])
l = db.issue.list()
ae(l, [])
class ExtendedTestCase(MyTestCase):
backend = 'anydbm'
def testCreation(self):
ae = self.assertEqual
# create the instance
init(self.dirname, 'extended', self.backend, 'sekrit')
# check we can load the package
instance = imp.load_package(self.dirname, self.dirname)
# and open the database
db = instance.open()
# check the basics of the schema and initial data set
l = db.priority.list()
ae(l, ['1', '2', '3', '4'])
l = db.status.list()
ae(l, ['1', '2', '3', '4', '5', '6', '7', '8'])
l = db.keyword.list()
ae(l, [])
l = db.user.list()
ae(l, ['1'])
l = db.msg.list()
ae(l, [])
l = db.file.list()
ae(l, [])
l = db.issue.list()
ae(l, [])
l = db.support.list()
ae(l, [])
l = db.rate.list()
ae(l, ['1', '2', '3'])
l = db.source.list()
ae(l, ['1', '2', '3', '4'])
l = db.platform.list()
ae(l, ['1', '2', '3'])
l = db.timelog.list()
ae(l, [])
def suite():
l = [unittest.makeSuite(ClassicTestCase, 'test'),
unittest.makeSuite(ExtendedTestCase, 'test')]
try:
import bsddb
x = ClassicTestCase
x.backend = 'bsddb'
l.append(unittest.makeSuite(x, 'test'))
x = ExtendedTestCase
x.backend = 'bsddb'
l.append(unittest.makeSuite(x, 'test'))
except:
print 'bsddb module not found, skipping bsddb DBTestCase'
# try:
# import bsddb3
# x = ClassicTestCase
# x.backend = 'bsddb3'
# l.append(unittest.makeSuite(x, 'test'))
# x = ExtendedTestCase
# x.backend = 'bsddb3'
# l.append(unittest.makeSuite(x, 'test'))
# except:
# print 'bsddb3 module not found, skipping bsddb3 DBTestCase'
return unittest.TestSuite(l)
#
# $Log: not supported by cvs2svn $
# Revision 1.6 2001/09/29 23:48:06 richard
# Bug fix for test_init on Windows.
# More documenation!!
#
# Revision 1.5 2001/08/29 06:23:59 richard
# Disabled the bsddb3 module entirely in the unit testing. See CHANGES for
# details.
#
# Revision 1.4 2001/08/07 00:24:43 richard
# stupid typo
#
# Revision 1.3 2001/08/07 00:15:51 richard
# Added the copyright/license notice to (nearly) all files at request of
# Bizar Software.
#
# Revision 1.2 2001/08/05 07:45:27 richard
# Added tests for instance initialisation
#
# Revision 1.1 2001/08/05 07:07:58 richard
# added tests for roundup.init - but they're disabled until I can figure _if_
# we can run them (import problems).
#
#
#
# vim: set filetype=python ts=4 sw=4 et si