[Zope-Checkins] CVS: Zope/lib/python/ZODB/tests - testZODB.py:1.4.4.1

Chris McDonough chrism@zope.com
Tue, 10 Sep 2002 23:36:39 -0400


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

Modified Files:
      Tag: chrism-install-branch
	testZODB.py 
Log Message:
Merging chrism-install-branch with HEAD changes.


=== Zope/lib/python/ZODB/tests/testZODB.py 1.4 => 1.4.4.1 ===
--- Zope/lib/python/ZODB/tests/testZODB.py:1.4	Wed Aug 14 18:07:09 2002
+++ Zope/lib/python/ZODB/tests/testZODB.py	Tue Sep 10 23:36:38 2002
@@ -94,6 +94,38 @@
         self._storage.close()
         removefs("ZODBTests.fs")
 
+    def checkUnmodifiedObject(self):
+        # Test that a transaction with only unmodified objects works
+        # correctly.  The specific sequence of events is:
+        #     - an object is modified
+        #     - it is registered with the transaction
+        #     - the object is explicitly "unmodified"
+        #     - the transaction commits, but now has no modified objects
+        # We'd like to avoid doing anything with the storage.
+        ltid = self._storage.lastTransaction()
+        _objects = get_transaction()._objects
+        self.assertEqual(len(_objects), 0)
+        r = self._db.open().root()
+        obj = r["test"][0]
+        obj[1] = 1
+        self.assertEqual(obj._p_changed, 1)
+        self.assertEqual(len(_objects), 1)
+        del obj._p_changed
+        self.assertEqual(obj._p_changed, None)
+        self.assertEqual(len(_objects), 1)
+        get_transaction().commit()
+        self.assertEqual(ltid, self._storage.lastTransaction())
+
+    def checkVersionOnly(self):
+        # Make sure the changes to make empty transactions a no-op
+        # still allow things like abortVersion().  This should work
+        # because abortVersion() calls tpc_begin() itself.
+        r = self._db.open("version").root()
+        r[1] = 1
+        get_transaction().commit()
+        self._db.abortVersion("version")
+        get_transaction().commit()
+
 def test_suite():
     return unittest.makeSuite(ZODBTests, 'check')