Code

fixed detection of bad date specs (sf bug 691439)
[roundup.git] / test / test_init.py
index 74017ba8d200f304282898ad5cb122918183ea50..b58d0cefa04a993467f1eb5881ff7e57faf48a68 100644 (file)
 # 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 $
+# $Id: test_init.py,v 1.22 2003-03-18 00:50:24 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:
@@ -43,7 +43,9 @@ class ClassicTestCase(MyTestCase):
         ae = self.assertEqual
 
         # create the instance
-        init(self.dirname, 'classic', self.backend, 'sekrit')
+        init.install(self.dirname, 'classic')
+        init.write_select_db(self.dirname, self.backend)
+        init.initialise(self.dirname, 'sekrit')
 
         # check we can load the package
         instance = imp.load_package(self.dirname, self.dirname)
@@ -59,7 +61,7 @@ class ClassicTestCase(MyTestCase):
         l = db.keyword.list()
         ae(l, [])
         l = db.user.list()
-        ae(l, ['1'])
+        ae(l, ['1', '2'])
         l = db.msg.list()
         ae(l, [])
         l = db.file.list()
@@ -67,97 +69,38 @@ class ClassicTestCase(MyTestCase):
         l = db.issue.list()
         ae(l, [])
 
-class ExtendedTestCase(MyTestCase):
-    backend = 'anydbm'
-    def testCreation(self):
-        ae = self.assertEqual
+class bsddbClassicTestCase(ClassicTestCase):
+    backend = 'bsddb'
 
-        # create the instance
-        init(self.dirname, 'extended', self.backend, 'sekrit')
+class bsddb3ClassicTestCase(ClassicTestCase):
+    backend = 'bsddb3'
 
-        # check we can load the package
-        instance = imp.load_package(self.dirname, self.dirname)
+class metakitClassicTestCase(ClassicTestCase):
+    backend = 'metakit'
 
-        # and open the database
-        db = instance.open()
+class mysqlClassicTestCase(ClassicTestCase):
+    backend = 'mysql'
 
-        # 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, [])
+class sqliteClassicTestCase(ClassicTestCase):
+    backend = 'sqlite'
 
 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'
+    l = [
+        unittest.makeSuite(ClassicTestCase, 'test'),
+    ]
+
+    from roundup import backends
+    if hasattr(backends, 'bsddb'):
+        l.append(unittest.makeSuite(bsddbClassicTestCase, 'test'))
+    if hasattr(backends, 'bsddb3'):
+        l.append(unittest.makeSuite(bsddb3ClassicTestCase, 'test'))
+    if hasattr(backends, 'metakit'):
+        l.append(unittest.makeSuite(metakitClassicTestCase, 'test'))
+    if hasattr(backends, 'mysql'):
+        l.append(unittest.makeSuite(mysqlClassicTestCase, 'test'))
+    if hasattr(backends, 'sqlite'):
+        l.append(unittest.makeSuite(sqliteClassicTestCase, 'test'))
 
     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