[Zope-Checkins] CVS: Zope3/lib/python/Zope/Event/tests - testDirectives.py:1.1.2.2 testObjectEvent.py:1.1.2.2

Steve Alexander steve@cat-box.net
Fri, 1 Mar 2002 11:09:12 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Event/tests
In directory cvs.zope.org:/tmp/cvs-serv694/lib/python/Zope/Event/tests

Modified Files:
      Tag: Zope-3x-branch
	testDirectives.py testObjectEvent.py 
Log Message:
Changed ObjectRemovedEvent to take an object, as well as the location, as a
payload.
Here's a use-case:

> I want to make a subscriber that listens
> to object events to tell me the full name of contacts that get removed.
> 
> To do this currently, I need to store the full name of each contact that
> gets created.
> 
> If the object were passed with objectremoved events, I could just ask
> the object.




=== Zope3/lib/python/Zope/Event/tests/testDirectives.py 1.1.2.1 => 1.1.2.2 ===
         publishEvent(ObjectAddedEvent('foo'))
         self.assertEqual(subscriber.notified,1)
-        publishEvent(ObjectRemovedEvent('foo'))
+        publishEvent(ObjectRemovedEvent('foo', object()))
         self.assertEqual(subscriber.notified,2)
         publishEvent(ObjectModifiedEvent('foo'))
         self.assertEqual(subscriber.notified,2) # NB: no increase ;-)


=== Zope3/lib/python/Zope/Event/tests/testObjectEvent.py 1.1.2.1 => 1.1.2.2 ===
 class TestObjectRemovedEvent(TestObjectAddedEvent):
 
-    klass = ObjectRemovedEvent
+    
+    location = '/some/location'
+    obj = object()
+    
+    def setUp(self):
+        self.event = ObjectRemovedEvent(self.location, self.obj)
+        
+    def testGetLocation(self):
+        "Test getLocation method"
+        self.assertEqual(self.event.getLocation(),self.location)
+        
+    def testGetObject(self):
+        "Test getObject method"
+        self.assertEqual(self.event.getObject(), self.obj)
+
+
 
 class TestObjectMovedEvent(TestObjectAddedEvent):