[Zope3-checkins] CVS: Zope3/src/zodb/btrees/tests - test_conflict.py:1.4
Jeremy Hylton
jeremy@zope.com
Thu, 9 Jan 2003 13:16:20 -0500
Update of /cvs-repository/Zope3/src/zodb/btrees/tests
In directory cvs.zope.org:/tmp/cvs-serv23546/zodb/btrees/tests
Modified Files:
test_conflict.py
Log Message:
Collector #121: ConflictResolvingStorage doesn't with builtin
_p_resolveConfict
Add several tests to test_conflict that test integration through zodb.
These tests should be backported to ZODB3.
=== Zope3/src/zodb/btrees/tests/test_conflict.py 1.3 => 1.4 ===
--- Zope3/src/zodb/btrees/tests/test_conflict.py:1.3 Thu Jan 9 12:51:58 2003
+++ Zope3/src/zodb/btrees/tests/test_conflict.py Thu Jan 9 13:16:17 2003
@@ -17,31 +17,28 @@
from zodb.btrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
from zodb.btrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
from zodb.btrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
-from unittest import TestCase, TestSuite, TextTestRunner, makeSuite
+from unittest import TestCase, TestSuite, makeSuite
-from transaction.interfaces import ConflictError
+from transaction import get_transaction
+from zodb.btrees.interfaces import BTreesConflictError as ConflictError
class Base:
""" Tests common to all types: sets, buckets, and BTrees """
+
+ storage = None
+
def tearDown(self):
- self.t = None
del self.t
+ if self.storage is not None:
+ self.storage.close()
+ self.storage.cleanup()
- def _getRoot(self):
+ def openDB(self):
from zodb.storage.file import FileStorage
from zodb.db import DB
n = 'fs_tmp__%s' % os.getpid()
- s = FileStorage(n)
- db = DB(s)
- root = db.open().root()
- return root
-
- def _closeDB(self, root):
- root._p_jar._db.close()
- root = None
-
- def _delDB(self):
- os.system('rm fs_tmp__*')
+ self.storage = FileStorage(n)
+ self.db = DB(self.storage)
class MappingBase(Base):
""" Tests common to mappings (buckets, btrees) """
@@ -70,6 +67,29 @@
return base, b1, b2, bm, e1, e2, items
+ def testSimpleConflict(self):
+ # Unlike all the other tests, invoke conflict resolution
+ # by committing a transaction and catching a conflict
+ # in the storage.
+ self.openDB()
+
+ r1 = self.db.open().root()
+ r1["t"] = self.t
+ get_transaction().commit()
+
+ r2 = self.db.open().root()
+ copy = r2["t"]
+ copy._p_activate()
+
+ self.assertEqual(self.t._p_serial, copy._p_serial)
+
+ self.t.update({1:2, 2:3})
+ get_transaction().commit()
+
+ copy.update({3:4})
+ get_transaction().commit()
+
+
def testMergeDelete(self):
base, b1, b2, bm, e1, e2, items = self._setupConflict()
del b1[items[0][0]]
@@ -384,7 +404,6 @@
TestIITreeSets,
TestIOBuckets, TestOOBuckets, TestOIBuckets, TestIIBuckets):
s = makeSuite(klass)
- print klass, s.countTestCases()
suite.addTest(makeSuite(klass))
return suite