[Zodb-checkins] CVS: Zope3/src/zodb/tests - test_connection.py:1.8

Albertas Agejevas alga at pov.lt
Thu Oct 9 14:04:59 EDT 2003


Update of /cvs-repository/Zope3/src/zodb/tests
In directory cvs.zope.org:/tmp/cvs-serv3595/tests

Modified Files:
	test_connection.py 
Log Message:
Fixes to Connection.add:
  * register the added object in _cache, so we can get(oid) it
  * register the object in _created, so it is dis-owned on abort.


=== Zope3/src/zodb/tests/test_connection.py 1.7 => 1.8 ===
--- Zope3/src/zodb/tests/test_connection.py:1.7	Wed Oct  8 04:20:30 2003
+++ Zope3/src/zodb/tests/test_connection.py	Thu Oct  9 14:04:58 2003
@@ -177,6 +177,7 @@
         # This is a more 'functional' test than test_add
         self.datamgr.add(self.obj)
         oid = self.obj._p_oid
+        self.assert_(self.datamgr.get(oid) is self.obj)
         self.datamgr.root()["obj"] = self.obj
         get_transaction().commit()
 
@@ -186,6 +187,15 @@
         self.assertEqual(obj2._p_oid, oid)
         self.assert_(cn2.get(oid) is obj2, "cn2.get(oid) is not obj2")
         self.assert_(self.obj is not obj2, "self.obj is obj2")
+
+    def testAddingAborted(self):
+        # Check that object is dis-owned on abort.
+        self.datamgr.add(self.obj)
+        oid = self.obj._p_oid
+        get_transaction().abort()
+        self.assert_(self.obj._p_oid is None)
+        self.assert_(self.obj._p_jar is None)
+        self.assertRaises(KeyError, self.datamgr.get, oid)
 
     def tearDown(self):
         get_transaction().abort()




More information about the Zodb-checkins mailing list