[Zope3-checkins] CVS: Zope3/lib/python/Zope/Event/tests - testDirectives.py:1.4 testEventService.py:1.4 testLogger.py:1.4 testObjectEvent.py:1.4

Jim Fulton jim@zope.com
Thu, 3 Oct 2002 16:53:54 -0400


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

Modified Files:
	testDirectives.py testEventService.py testLogger.py 
	testObjectEvent.py 
Log Message:
Refactored Object events:

- All ObjectEvents now have an object attribute, which is the
  the subject of the event.

- Changed the getLocation and getFromLocation methods to location and
  fromLocation attributes.

Refactored HubEvents:

- Changed getObject, getRuid, and getLocation methods to object, hid,
  and location attributes.




=== Zope3/lib/python/Zope/Event/tests/testDirectives.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/Event/tests/testDirectives.py:1.3	Wed Jul 17 12:54:21 2002
+++ Zope3/lib/python/Zope/Event/tests/testDirectives.py	Thu Oct  3 16:53:22 2002
@@ -65,11 +65,11 @@
                              filter="Zope.Event.tests.subscriber.filter"/>
             """)))
 
-        publishEvent(None,ObjectAddedEvent('foo'))
+        publishEvent(None,ObjectAddedEvent(None, 'foo'))
         self.assertEqual(subscriber.notified,1)
-        publishEvent(None,ObjectRemovedEvent('foo', object()))
+        publishEvent(None,ObjectRemovedEvent(object(), 'foo'))
         self.assertEqual(subscriber.notified,2)
-        publishEvent(None,ObjectModifiedEvent('foo'))
+        publishEvent(None,ObjectModifiedEvent(None, 'foo'))
         self.assertEqual(subscriber.notified,2) # NB: no increase ;-)
         publishEvent(None,DummyEvent())
         self.assertEqual(subscriber.notified,4) # NB: increased by 2 ;-)


=== Zope3/lib/python/Zope/Event/tests/testEventService.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/Event/tests/testEventService.py:1.3	Wed Jul 17 12:54:21 2002
+++ Zope3/lib/python/Zope/Event/tests/testEventService.py	Thu Oct  3 16:53:22 2002
@@ -44,7 +44,7 @@
     def setUp(self):
         CleanUp.setUp(self)
         self.service = GlobalEventService()
-        self.event = ObjectAddedEvent('/foo')
+        self.event = ObjectAddedEvent(None, '/foo')
         self.subscriber = DummySubscriber()
         
     def testSubscribe1(self):
@@ -169,7 +169,7 @@
         "Test selective unsubscribe"
         subscriber2=DummySubscriber()
         filter=DummyFilter()
-        event2=ObjectModifiedEvent('/foo')
+        event2=ObjectModifiedEvent(None, '/foo')
         self.service.subscribe(
             self.subscriber)
         self.service.subscribe(


=== Zope3/lib/python/Zope/Event/tests/testLogger.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/Event/tests/testLogger.py:1.3	Wed Jul 17 12:54:21 2002
+++ Zope3/lib/python/Zope/Event/tests/testLogger.py	Thu Oct  3 16:53:22 2002
@@ -55,7 +55,7 @@
         # register a logger
         subscribe(self.eventlogger)
         # send an event
-        publishEvent(None, ObjectAddedEvent('foo'))
+        publishEvent(None, ObjectAddedEvent(None, 'foo'))
 
     def tearDown(self):
         unsubscribe(self.eventlogger)
@@ -71,7 +71,7 @@
             'Event.Logger',
             BLATHER,
             'Zope.Event.ObjectEvent.ObjectAddedEvent',
-            "{'_ObjectAddedEvent__location': 'foo'}\n",
+            "[('location', 'foo'), ('object', None)]\n",
             None,
             )
             ])
@@ -89,7 +89,7 @@
             'Event.Logger',
             PANIC,
             'Zope.Event.ObjectEvent.ObjectAddedEvent',
-            "{'_ObjectAddedEvent__location': 'foo'}\n",
+            "[('location', 'foo'), ('object', None)]\n",
             None,
             )
             ])


=== Zope3/lib/python/Zope/Event/tests/testObjectEvent.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/Event/tests/testObjectEvent.py:1.3	Wed Jul 17 12:54:21 2002
+++ Zope3/lib/python/Zope/Event/tests/testObjectEvent.py	Thu Oct  3 16:53:22 2002
@@ -25,14 +25,17 @@
 class TestObjectAddedEvent(unittest.TestCase):
     
     location = '/some/location'
+    object = object()
     klass = ObjectAddedEvent
     
     def setUp(self):
-        self.event = self.klass(self.location)
+        self.event = self.klass(self.object, self.location)
         
     def testGetLocation(self):
-        "Test getLocation method"
-        self.assertEqual(self.event.getLocation(),self.location)
+        self.assertEqual(self.event.location, self.location)
+        
+    def testGetObject(self):
+        self.assertEqual(self.event.object, self.object)
 
 class TestObjectModifiedEvent(TestObjectAddedEvent):
 
@@ -42,18 +45,15 @@
 
     
     location = '/some/location'
-    obj = object()
     
     def setUp(self):
-        self.event = ObjectRemovedEvent(self.location, self.obj)
+        self.event = ObjectRemovedEvent(self.object, self.location)
         
     def testGetLocation(self):
-        "Test getLocation method"
-        self.assertEqual(self.event.getLocation(),self.location)
+        self.assertEqual(self.event.location, self.location)
         
     def testGetObject(self):
-        "Test getObject method"
-        self.assertEqual(self.event.getObject(), self.obj)
+        self.assertEqual(self.event.object, self.object)
 
 
 
@@ -62,11 +62,11 @@
     from_location = '/some/other/location'
     
     def setUp(self):
-        self.event = ObjectMovedEvent(self.from_location, self.location)
+        self.event = ObjectMovedEvent(self.object,
+                                      self.from_location, self.location)
 
     def testFromLocation(self):
-        "Test getFromLocation method"
-        self.assertEqual(self.event.getFromLocation(),self.from_location)
+        self.assertEqual(self.event.fromLocation, self.from_location)
         
 def test_suite():
     return unittest.TestSuite((unittest.makeSuite(TestObjectAddedEvent),