Code

added test for error in sqlite backend, and fixed *dbm backend error
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 3 Mar 2003 21:05:19 +0000 (21:05 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Mon, 3 Mar 2003 21:05:19 +0000 (21:05 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1563 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/backends/back_anydbm.py
test/test_db.py

index 8a30e25334f6747d0b9c7e7b220d31bdb7520a5f..df10104c4df459b96aaa39f062af060b75a81aab 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-#$Id: back_anydbm.py,v 1.107 2003-02-28 03:33:46 richard Exp $
+#$Id: back_anydbm.py,v 1.108 2003-03-03 21:05:17 richard Exp $
 '''
 This module defines a backend that saves the hyperdatabase in a database
 chosen by anydbm. It is guaranteed to always be available in python
@@ -1537,16 +1537,16 @@ class Class(hyperdb.Class):
         res = []
 
         # start off with the new nodes
-        if self.db.newnodes.has_key(classname):
-            res += self.db.newnodes[classname].keys()
+        if self.db.newnodes.has_key(self.classname):
+            res += self.db.newnodes[self.classname].keys()
 
         if db is None:
-            db = self.db.getclassdb(classname)
+            db = self.db.getclassdb(self.classname)
         res = res + db.keys()
 
         # remove the uncommitted, destroyed nodes
-        if self.db.destroyednodes.has_key(classname):
-            for nodeid in self.db.destroyednodes[classname].keys():
+        if self.db.destroyednodes.has_key(self.classname):
+            for nodeid in self.db.destroyednodes[self.classname].keys():
                 if db.has_key(nodeid):
                     res.remove(nodeid)
 
index 857fa5b35b6eb176f067790dcaf47d614850662d..2ca56b0f8790ea1aa17eacd29c7e14e92713fceb 100644 (file)
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: test_db.py,v 1.72 2003-02-27 11:07:39 richard Exp $ 
+# $Id: test_db.py,v 1.73 2003-03-03 21:05:19 richard Exp $ 
 
 import unittest, os, shutil, time
 
 from roundup.hyperdb import String, Password, Link, Multilink, Date, \
-    Interval, DatabaseError, Boolean, Number
+    Interval, DatabaseError, Boolean, Number, Node
 from roundup import date, password
 from roundup.indexer import Indexer
 
@@ -653,6 +653,27 @@ class anydbmDBTestCase(MyTestCase):
         ae(filt(None, {'nosy': '2', 'status': '1'}, ('+','id'), (None,None)),
             ['3'])
 
+    def testNode1(self):
+        node1 = self.db.user.getnode('1')
+        name = node1.username
+        self.db.user.set('1', username = name+name)
+        name1 = node1.username
+        self.db.rollback()
+        node2 = self.db.user.getnode('1')
+        self.assertEqual(name, node1.username)
+        self.assertEqual(name, node2.username)
+
+    def testNode2(self):
+        node1 = Node(self.db.user, '1')
+        name = node1.username
+        self.db.user.set('1', username = name+name)
+        name1 = node1.username
+        self.db.rollback()
+        node2 = Node(self.db.user, '1')
+        self.assertEqual(name, node1.username)
+        self.assertEqual(name, node2.username)
+
+
 # TODO test auditors and reactors
 
 class anydbmReadOnlyDBTestCase(MyTestCase):
@@ -895,28 +916,28 @@ def suite():
 
     from roundup import backends
     p = []
-    if hasattr(backends, 'mysql'):
-        from roundup.backends import mysql
-        try:
-            # Check if we can run mysql tests
-            import MySQLdb
-            db = mysql.Database(nodbconfig, 'admin')
-            db.conn.select_db(config.MYSQL_DBNAME)
-            db.sql("SHOW TABLES");
-            tables = db.sql_fetchall()
-            if tables:
-                # Database should be empty. We don't dare to delete any data
-                raise DatabaseError, "(Database %s contains tables)" % config.MYSQL_DBNAME
-            db.sql("DROP DATABASE %s" % config.MYSQL_DBNAME)
-            db.sql("CREATE DATABASE %s" % config.MYSQL_DBNAME)
-            db.close()
-        except (MySQLdb.ProgrammingError, DatabaseError), msg:
-            print "Warning! Mysql tests will not be performed", msg
-            print "See doc/mysql.txt for more details."
-        else:
-            p.append('mysql')
-            l.append(unittest.makeSuite(mysqlDBTestCase, 'test'))
-            l.append(unittest.makeSuite(mysqlReadOnlyDBTestCase, 'test'))
+#    if hasattr(backends, 'mysql'):
+#        from roundup.backends import mysql
+#        try:
+#            # Check if we can run mysql tests
+#            import MySQLdb
+#            db = mysql.Database(nodbconfig, 'admin')
+#            db.conn.select_db(config.MYSQL_DBNAME)
+#            db.sql("SHOW TABLES");
+#            tables = db.sql_fetchall()
+#            if tables:
+#                # Database should be empty. We don't dare to delete any data
+#                raise DatabaseError, "(Database %s contains tables)" % config.MYSQL_DBNAME
+#            db.sql("DROP DATABASE %s" % config.MYSQL_DBNAME)
+#            db.sql("CREATE DATABASE %s" % config.MYSQL_DBNAME)
+#            db.close()
+#        except (MySQLdb.ProgrammingError, DatabaseError), msg:
+#            print "Warning! Mysql tests will not be performed", msg
+#            print "See doc/mysql.txt for more details."
+#        else:
+#            p.append('mysql')
+#            l.append(unittest.makeSuite(mysqlDBTestCase, 'test'))
+#            l.append(unittest.makeSuite(mysqlReadOnlyDBTestCase, 'test'))
     #return unittest.TestSuite(l)
 
     if hasattr(backends, 'gadfly'):