[Zodb-checkins] CVS: Zope/lib/python/ZODB/tests - ConflictResolution.py:1.8.26.1 PackableStorage.py:1.13.26.1 StorageTestBase.py:1.17.26.1 Synchronization.py:1.6.26.1 testFileStorage.py:1.20.2.1

Andreas Jung andreas@andreas-jung.com
Sat, 9 Nov 2002 03:43:32 -0500


Update of /cvs-repository/Zope/lib/python/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv26094/lib/python/ZODB/tests

Modified Files:
      Tag: ajung-restructuredtext-integration-branch
	ConflictResolution.py PackableStorage.py StorageTestBase.py 
	Synchronization.py testFileStorage.py 
Log Message:
merge from trunk


=== Zope/lib/python/ZODB/tests/ConflictResolution.py 1.8 => 1.8.26.1 ===
--- Zope/lib/python/ZODB/tests/ConflictResolution.py:1.8	Wed Aug 14 18:07:09 2002
+++ Zope/lib/python/ZODB/tests/ConflictResolution.py	Sat Nov  9 03:43:00 2002
@@ -104,7 +104,7 @@
         # pickle is to commit two different transactions relative to
         # revid1 that add two to _value.
         revid2 = self._dostoreNP(oid, revid=revid1, data=zodb_pickle(obj))
-        self.assertRaises(AttributeError,
+        self.assertRaises(ConflictError,
                           self._dostoreNP,
                           oid, revid=revid1, data=zodb_pickle(obj))
 
@@ -122,7 +122,7 @@
         # pickle is to commit two different transactions relative to
         # revid1 that add two to _value.
         revid2 = self._dostoreNP(oid, revid=revid1, data=zodb_pickle(obj))
-        self.assertRaises(TypeError,
+        self.assertRaises(ConflictError,
                           self._dostoreNP,
                           oid, revid=revid1, data=zodb_pickle(obj))
 


=== Zope/lib/python/ZODB/tests/PackableStorage.py 1.13 => 1.13.26.1 ===
--- Zope/lib/python/ZODB/tests/PackableStorage.py:1.13	Wed Aug 14 18:07:09 2002
+++ Zope/lib/python/ZODB/tests/PackableStorage.py	Sat Nov  9 03:43:00 2002
@@ -13,6 +13,8 @@
     from StringIO import StringIO
 
 import time
+from ZODB import DB
+from Persistence import Persistent
 from ZODB.referencesf import referencesf
 
 
@@ -42,6 +44,9 @@
         return self._oid
 
 
+class C(Persistent):
+    pass
+
 # Here's where all the magic occurs.  Sadly, the pickle module is a bit
 # underdocumented, but here's what happens: by setting the persistent_id
 # attribute to getpersid() on the pickler, that function gets called for every
@@ -159,8 +164,10 @@
         eq(pobj.value, 3)
         # Now pack all transactions; need to sleep a second to make
         # sure that the pack time is greater than the last commit time.
-        time.sleep(1)
-        self._storage.pack(time.time(), referencesf)
+        now = packtime = time.time()
+        while packtime <= now:
+            packtime = time.time()
+        self._storage.pack(packtime, referencesf)
         # All revisions of the object should be gone, since there is no
         # reference from the root object to this object.
         raises(KeyError, self._storage.loadSerial, oid, revid1)
@@ -210,8 +217,10 @@
         eq(pobj.value, 3)
         # Now pack just revisions 1 and 2.  The object's current revision
         # should stay alive because it's pointed to by the root.
-        time.sleep(1)
-        self._storage.pack(time.time(), referencesf)
+        now = packtime = time.time()
+        while packtime <= now:
+            packtime = time.time()
+        self._storage.pack(packtime, referencesf)
         # Make sure the revisions are gone, but that object zero and revision
         # 3 are still there and correct
         data, revid = self._storage.load(ZERO, '')
@@ -287,8 +296,10 @@
         # Now pack just revisions 1 and 2 of object1.  Object1's current
         # revision should stay alive because it's pointed to by the root, as
         # should Object2's current revision.
-        time.sleep(1)
-        self._storage.pack(time.time(), referencesf)
+        now = packtime = time.time()
+        while packtime <= now:
+            packtime = time.time()
+        self._storage.pack(packtime, referencesf)
         # Make sure the revisions are gone, but that object zero, object2, and
         # revision 3 of object1 are still there and correct.
         data, revid = self._storage.load(ZERO, '')
@@ -312,3 +323,43 @@
         pobj = pickle.loads(data)
         eq(pobj.getoid(), oid2)
         eq(pobj.value, 11)
+
+    def checkPackUnlinkedFromRoot(self):
+        eq = self.assertEqual
+        db = DB(self._storage)
+        conn = db.open()
+        root = conn.root()
+
+        txn = get_transaction()
+        txn.note('root')
+        txn.commit()
+
+        now = packtime = time.time()
+        while packtime <= now:
+            packtime = time.time()
+
+        obj = C()
+        obj.value = 7
+
+        root['obj'] = obj
+        txn = get_transaction()
+        txn.note('root -> o1')
+        txn.commit()
+
+        del root['obj']
+        txn = get_transaction()
+        txn.note('root -x-> o1')
+        txn.commit()
+
+        self._storage.pack(packtime, referencesf)
+
+        log = self._storage.undoLog()
+        tid = log[0]['id']
+        db.undo(tid)
+        txn = get_transaction()
+        txn.note('undo root -x-> o1')
+        txn.commit()
+
+        conn.sync()
+
+        eq(root['obj'].value, 7)


=== Zope/lib/python/ZODB/tests/StorageTestBase.py 1.17 => 1.17.26.1 ===
--- Zope/lib/python/ZODB/tests/StorageTestBase.py:1.17	Wed Aug 14 18:07:09 2002
+++ Zope/lib/python/ZODB/tests/StorageTestBase.py	Sat Nov  9 03:43:00 2002
@@ -100,8 +100,7 @@
 
     A helper for function _handle_all_serials().
     """
-    args = (oid,) + args
-    return apply(handle_all_serials, args)[oid]
+    return handle_all_serials(oid, *args)[oid]
 
 def import_helper(name):
     mod = __import__(name)


=== Zope/lib/python/ZODB/tests/Synchronization.py 1.6 => 1.6.26.1 ===
--- Zope/lib/python/ZODB/tests/Synchronization.py:1.6	Wed Aug 14 18:07:09 2002
+++ Zope/lib/python/ZODB/tests/Synchronization.py	Sat Nov  9 03:43:00 2002
@@ -63,8 +63,7 @@
 ##        self.assertRaises(StorageTransactionError, callable *args)
 
     def verifyNotCommitting(self, callable, *args):
-        args = (StorageTransactionError, callable) + args
-        apply(self.assertRaises, args)
+        self.assertRaises(StorageTransactionError, callable, *args)
 
     def verifyWrongTrans(self, callable, *args):
         t = Transaction()


=== Zope/lib/python/ZODB/tests/testFileStorage.py 1.20 => 1.20.2.1 ===
--- Zope/lib/python/ZODB/tests/testFileStorage.py:1.20	Thu Oct 24 09:51:56 2002
+++ Zope/lib/python/ZODB/tests/testFileStorage.py	Sat Nov  9 03:43:00 2002
@@ -32,12 +32,8 @@
     ):
 
     def open(self, **kwargs):
-        if kwargs:
-            self._storage = apply(ZODB.FileStorage.FileStorage,
-                                  ('FileStorageTests.fs',), kwargs)
-        else:
-            self._storage = ZODB.FileStorage.FileStorage(
-                'FileStorageTests.fs', **kwargs)
+        self._storage = ZODB.FileStorage.FileStorage('FileStorageTests.fs',
+                                                     **kwargs)
 
     def setUp(self):
         self.open(create=1)