X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=test%2Ftest_init.py;h=1a9520ddf9b28a4e9ab64c06e24ebe417026d509;hb=d0d249e39fe1046b4bb600487b2aa95ca70e8085;hp=f9430946e54c799e4da3e9a20cfdb1ee834b9348;hpb=67e9d3bb7d5855c1c864d686bdeeedd8a0676ace;p=roundup.git diff --git a/test/test_init.py b/test/test_init.py index f943094..1a9520d 100644 --- a/test/test_init.py +++ b/test/test_init.py @@ -1,24 +1,41 @@ -# $Id: test_init.py,v 1.2 2001-08-05 07:45:27 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_init.py,v 1.13 2002-07-14 02:05:54 richard Exp $ import unittest, os, shutil, errno, imp, sys -from roundup.init import init +from roundup import init class MyTestCase(unittest.TestCase): count = 0 def setUp(self): MyTestCase.count = MyTestCase.count + 1 - self.dirname = '_test_%s'%self.count + self.dirname = '_test_init_%s'%self.count try: shutil.rmtree(self.dirname) except OSError, error: - if error.errno != errno.ENOENT: raise + if error.errno not in (errno.ENOENT, errno.ESRCH): raise def tearDown(self): try: shutil.rmtree(self.dirname) except OSError, error: - if error.errno != errno.ENOENT: raise + if error.errno not in (errno.ENOENT, errno.ESRCH): raise class ClassicTestCase(MyTestCase): backend = 'anydbm' @@ -26,7 +43,8 @@ class ClassicTestCase(MyTestCase): ae = self.assertEqual # create the instance - init(self.dirname, 'classic', self.backend, 'sekrit') + init.install(self.dirname, 'classic', self.backend) + init.initialise(self.dirname, 'sekrit') # check we can load the package instance = imp.load_package(self.dirname, self.dirname) @@ -56,7 +74,8 @@ class ExtendedTestCase(MyTestCase): ae = self.assertEqual # create the instance - init(self.dirname, 'extended', self.backend, 'sekrit') + init.install(self.dirname, 'extended', self.backend) + init.initialise(self.dirname, 'sekrit') # check we can load the package instance = imp.load_package(self.dirname, self.dirname) @@ -90,35 +109,94 @@ class ExtendedTestCase(MyTestCase): l = db.timelog.list() ae(l, []) +class bsddbClassicTestCase(ClassicTestCase): + backend = 'bsddb' +class bsddbExtendedTestCase(ExtendedTestCase): + backend = 'bsddb' + +class bsddb3ClassicTestCase(ClassicTestCase): + backend = 'bsddb3' +class bsddb3ExtendedTestCase(ExtendedTestCase): + backend = 'bsddb3' + +class metakitClassicTestCase(ClassicTestCase): + backend = 'metakit' +class metakitExtendedTestCase(ExtendedTestCase): + backend = 'metakit' + def suite(): - l = [unittest.makeSuite(ClassicTestCase, 'test'), - unittest.makeSuite(ExtendedTestCase, 'test')] + 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')) + l.append(unittest.makeSuite(bsddbClassicTestCase, 'test')) + l.append(unittest.makeSuite(bsddbExtendedTestCase, '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')) + l.append(unittest.makeSuite(bsddb3ClassicTestCase, 'test')) + l.append(unittest.makeSuite(bsddb3ExtendedTestCase, 'test')) except: print 'bsddb3 module not found, skipping bsddb3 DBTestCase' + try: + import metakit + l.append(unittest.makeSuite(metakitClassicTestCase, 'test')) + l.append(unittest.makeSuite(metakitExtendedTestCase, 'test')) + except: + print 'metakit module not found, skipping metakit DBTestCase' + return unittest.TestSuite(l) # # $Log: not supported by cvs2svn $ +# Revision 1.12 2002/07/11 01:13:13 richard +# *** empty log message *** +# +# Revision 1.11 2002/07/11 01:12:34 richard +# Forgot to add to init tests +# +# Revision 1.10 2002/06/11 04:59:14 richard +# enabled testing of bsddb in test_init +# +# Revision 1.9 2002/05/23 04:26:05 richard +# 'I must run unit tests before committing\n' * 100 +# +# Revision 1.8 2002/05/15 03:27:16 richard +# . fixed SCRIPT_NAME in ZRoundup for instances not at top level of Zope +# (thanks dman) +# . fixed some sorting issues that were breaking some unit tests under py2.2 +# . mailgw test output dir was confusing the init test (but only on 2.2 *shrug*) +# +# fixed bug in the init unit test that meant only the bsddb test ran if it +# could (it clobbered the anydbm test) +# +# Revision 1.7 2001/10/28 22:51:38 richard +# Fixed ENOENT/WindowsError thing, thanks Juergen Hermann +# +# 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).