summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 514e7a0)
raw | patch | inline | side by side (parent: 514e7a0)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 10 Dec 2001 23:17:20 +0000 (23:17 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 10 Dec 2001 23:17:20 +0000 (23:17 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@453 57a73879-2fb5-44c3-a270-3262357dd7e2
test/test_db.py | patch | blob | history |
diff --git a/test/test_db.py b/test/test_db.py
index 49074a7f4615960368b8d16217a93c80a1e7bd73..08b918adebc927eff22b37d4f5f6b738fbf7dd50 100644 (file)
--- a/test/test_db.py
+++ b/test/test_db.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: test_db.py,v 1.10 2001-12-03 21:33:39 richard Exp $
+# $Id: test_db.py,v 1.11 2001-12-10 23:17:20 richard Exp $
import unittest, os, shutil
Class(db, "user", username=String(), password=Password())
Class(db, "issue", title=String(), status=Link("status"),
nosy=Multilink("user"))
-
-#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
+ db.commit()
class MyTestCase(unittest.TestCase):
-# def defaultTestResult(self):
-# return MyTestResult()
def tearDown(self):
- if self.db is not None:
+ if os.path.exists('_test_dir'):
shutil.rmtree('_test_dir')
-class DBTestCase(MyTestCase):
+class anydbmDBTestCase(MyTestCase):
def setUp(self):
from roundup.backends import anydbm
# remove previous test, ignore errors
self.db.status.history('1')
self.db.status.history('2')
+ def testTransactions(self):
+ num_issues = len(self.db.issue.list())
+ self.db.issue.create(title="don't commit me!", status='1')
+ self.assertNotEqual(num_issues, len(self.db.issue.list()))
+ self.db.rollback()
+ self.assertEqual(num_issues, len(self.db.issue.list()))
+ self.db.issue.create(title="please commit me!", status='1')
+ self.assertNotEqual(num_issues, len(self.db.issue.list()))
+ self.db.commit()
+ self.assertNotEqual(num_issues, len(self.db.issue.list()))
+ self.db.rollback()
+ self.assertNotEqual(num_issues, len(self.db.issue.list()))
+
def testExceptions(self):
# this tests the exceptions that should be raised
ar = self.assertRaises
pass
-class ReadOnlyDBTestCase(MyTestCase):
+class anydbmReadOnlyDBTestCase(MyTestCase):
def setUp(self):
from roundup.backends import anydbm
# remove previous test, ignore errors
ar(DatabaseError, self.db.status.retire, '1')
-class bsddbDBTestCase(DBTestCase):
+class bsddbDBTestCase(anydbmDBTestCase):
def setUp(self):
from roundup.backends import bsddb
# remove previous test, ignore errors
self.db = bsddb.Database('_test_dir', 'test')
setupSchema(self.db, 1)
-class bsddbReadOnlyDBTestCase(ReadOnlyDBTestCase):
+class bsddbReadOnlyDBTestCase(anydbmReadOnlyDBTestCase):
def setUp(self):
from roundup.backends import bsddb
# remove previous test, ignore errors
setupSchema(self.db, 0)
-class bsddb3DBTestCase(DBTestCase):
+class bsddb3DBTestCase(anydbmDBTestCase):
def setUp(self):
from roundup.backends import bsddb3
# remove previous test, ignore errors
self.db = bsddb3.Database('_test_dir', 'test')
setupSchema(self.db, 1)
-class bsddb3ReadOnlyDBTestCase(ReadOnlyDBTestCase):
+class bsddb3ReadOnlyDBTestCase(anydbmReadOnlyDBTestCase):
def setUp(self):
from roundup.backends import bsddb3
# remove previous test, ignore errors
def suite():
- l = [unittest.makeSuite(DBTestCase, 'test'),
- unittest.makeSuite(ReadOnlyDBTestCase, 'test')]
+ l = [unittest.makeSuite(anydbmDBTestCase, 'test'),
+ unittest.makeSuite(anydbmReadOnlyDBTestCase, 'test')
+ ]
try:
import bsddb
#
# $Log: not supported by cvs2svn $
+# Revision 1.10 2001/12/03 21:33:39 richard
+# Fixes so the tests use commit and not close
+#
# Revision 1.9 2001/12/02 05:06:16 richard
# . We now use weakrefs in the Classes to keep the database reference, so
# the close() method on the database is no longer needed.