diff --git a/test/test_db.py b/test/test_db.py
index 9a149a41cfb99a13909e3074dbc77ee36b86ea9b..d5318b65500c600299c603b2a3f224e13a78cbf2 100644 (file)
--- a/test/test_db.py
+++ b/test/test_db.py
-# $Id: test_db.py,v 1.2 2001-07-29 04:09:20 richard Exp $
+#
+# 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_db.py,v 1.7 2001-08-29 06:23:59 richard Exp $
import unittest, os, shutil
-from roundup.backends import anydbm
from roundup.hyperdb import String, Link, Multilink, Date, Interval, Class, \
DatabaseError
Class(db, "issue", title=String(), status=Link("status"),
nosy=Multilink("user"))
-class DBTestCase(unittest.TestCase):
+#class MyTestResult(unittest._TestResult):
+# def addError(self, test, err):
+# print `err`
+# TestResult.addError(self, test, err)
+# if self.showAll:
+# self.stream.writeln("ERROR")
+# elif self.dots:
+# self.stream.write('E')
+# if err[0] is KeyboardInterrupt:
+# self.shouldStop = 1
+
+class MyTestCase(unittest.TestCase):
+# def defaultTestResult(self):
+# return MyTestResult()
+ def tearDown(self):
+ if self.db is not None:
+ self.db.close()
+ shutil.rmtree('_test_dir')
+
+class DBTestCase(MyTestCase):
def setUp(self):
- class Database(anydbm.Database):
- pass
+ from roundup.backends import anydbm
# remove previous test, ignore errors
if os.path.exists('_test_dir'):
shutil.rmtree('_test_dir')
os.mkdir('_test_dir')
- self.db = Database('_test_dir', 'test')
+ self.db = anydbm.Database('_test_dir', 'test')
setupSchema(self.db, 1)
- def tearDown(self):
- self.db.close()
- shutil.rmtree('_test_dir')
-
def testChanges(self):
self.db.issue.create(title="spam", status='1')
self.db.issue.create(title="eggs", status='2')
nosy=['10'])
def testRetire(self):
- ''' test retiring a node
- '''
pass
-class ReadOnlyDBTestCase(unittest.TestCase):
+class ReadOnlyDBTestCase(MyTestCase):
def setUp(self):
- class Database(anydbm.Database):
- pass
+ from roundup.backends import anydbm
# remove previous test, ignore errors
if os.path.exists('_test_dir'):
shutil.rmtree('_test_dir')
os.mkdir('_test_dir')
- db = Database('_test_dir', 'test')
+ db = anydbm.Database('_test_dir', 'test')
setupSchema(db, 1)
db.close()
- self.db = Database('_test_dir')
+ self.db = anydbm.Database('_test_dir')
setupSchema(self.db, 0)
- def tearDown(self):
- self.db.close()
- shutil.rmtree('_test_dir')
-
def testExceptions(self):
# this tests the exceptions that should be raised
ar = self.assertRaises
ar(DatabaseError, self.db.status.retire, '1')
+class bsddbDBTestCase(DBTestCase):
+ def setUp(self):
+ from roundup.backends import bsddb
+ # remove previous test, ignore errors
+ if os.path.exists('_test_dir'):
+ shutil.rmtree('_test_dir')
+ os.mkdir('_test_dir')
+ self.db = bsddb.Database('_test_dir', 'test')
+ setupSchema(self.db, 1)
+
+class bsddbReadOnlyDBTestCase(ReadOnlyDBTestCase):
+ def setUp(self):
+ from roundup.backends import bsddb
+ # remove previous test, ignore errors
+ if os.path.exists('_test_dir'):
+ shutil.rmtree('_test_dir')
+ os.mkdir('_test_dir')
+ db = bsddb.Database('_test_dir', 'test')
+ setupSchema(db, 1)
+ db.close()
+ self.db = bsddb.Database('_test_dir')
+ setupSchema(self.db, 0)
+
+
+class bsddb3DBTestCase(DBTestCase):
+ def setUp(self):
+ from roundup.backends import bsddb3
+ # remove previous test, ignore errors
+ if os.path.exists('_test_dir'):
+ shutil.rmtree('_test_dir')
+ os.mkdir('_test_dir')
+ self.db = bsddb3.Database('_test_dir', 'test')
+ setupSchema(self.db, 1)
+
+class bsddb3ReadOnlyDBTestCase(ReadOnlyDBTestCase):
+ def setUp(self):
+ from roundup.backends import bsddb3
+ # remove previous test, ignore errors
+ if os.path.exists('_test_dir'):
+ shutil.rmtree('_test_dir')
+ os.mkdir('_test_dir')
+ db = bsddb3.Database('_test_dir', 'test')
+ setupSchema(db, 1)
+ db.close()
+ self.db = bsddb3.Database('_test_dir')
+ setupSchema(self.db, 0)
+
+
def suite():
- db = unittest.makeSuite(DBTestCase, 'test')
- readonlydb = unittest.makeSuite(ReadOnlyDBTestCase, 'test')
- return unittest.TestSuite((db, readonlydb))
+ l = [unittest.makeSuite(DBTestCase, 'test'),
+ unittest.makeSuite(ReadOnlyDBTestCase, 'test')]
+
+ try:
+ import bsddb
+ l.append(unittest.makeSuite(bsddbDBTestCase, 'test'))
+ l.append(unittest.makeSuite(bsddbReadOnlyDBTestCase, 'test'))
+ except:
+ print 'bsddb module not found, skipping bsddb DBTestCase'
+# try:
+# import bsddb3
+# l.append(unittest.makeSuite(bsddb3DBTestCase, 'test'))
+# l.append(unittest.makeSuite(bsddb3ReadOnlyDBTestCase, 'test'))
+# except:
+# print 'bsddb3 module not found, skipping bsddb3 DBTestCase'
+
+ return unittest.TestSuite(l)
#
# $Log: not supported by cvs2svn $
+# Revision 1.6 2001/08/07 00:24:43 richard
+# stupid typo
+#
+# Revision 1.5 2001/08/07 00:15:51 richard
+# Added the copyright/license notice to (nearly) all files at request of
+# Bizar Software.
+#
+# Revision 1.4 2001/07/30 03:45:56 richard
+# Added more DB to test_db. Can skip tests where imports fail.
+#
+# Revision 1.3 2001/07/29 07:01:39 richard
+# Added vim command to all source so that we don't get no steenkin' tabs :)
+#
+# Revision 1.2 2001/07/29 04:09:20 richard
+# Added the fabricated property "id" to all hyperdb classes.
+#
# Revision 1.1 2001/07/27 06:55:07 richard
# moving tests -> test
#
# Added id and log to tests files...
#
#
+# vim: set filetype=python ts=4 sw=4 et si