[Zope3-checkins] CVS: Zope3/src/persistence/tests - test_persistence.py:1.3

Jeremy Hylton jeremy@zope.com
Mon, 24 Feb 2003 17:04:22 -0500


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

Modified Files:
	test_persistence.py 
Log Message:
Make sure _p_deactivate() does nothing unless object has oid and dm.

Add test that object states in UPTODATE state when deactivate is
called without an oid.


=== Zope3/src/persistence/tests/test_persistence.py 1.2 => 1.3 ===
--- Zope3/src/persistence/tests/test_persistence.py:1.2	Wed Dec 25 09:12:13 2002
+++ Zope3/src/persistence/tests/test_persistence.py	Mon Feb 24 17:03:52 2003
@@ -113,6 +113,20 @@
         p._p_activate()
         self.assertEqual(p.x, 42)
 
+    def testDeactivate(self):
+        p = self.klass()
+        dm = DM()
+        p._p_oid = 1
+        p._p_deactivate() # this deactive has no effect
+        self.assertEqual(p._p_state, 0)
+        p._p_jar = dm
+        p._p_changed = 0
+        p._p_deactivate()
+        # XXX does this really test the activate method?
+        self.assertEqual(p._p_state, 3)
+        p._p_activate()
+        self.assertEqual(p.x, 42)
+
     def testInterface(self):
         self.assert_(IPersistent.isImplementedByInstancesOf(Persistent),
                      "%s does not implement IPersistent" % Persistent)