[Zope3-checkins] CVS: Zope3/lib/python/Zope/ObjectHub/tests - testHubEvent.py:1.2 testObjectHub.py:1.8

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


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

Modified Files:
	testHubEvent.py testObjectHub.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/ObjectHub/tests/testHubEvent.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/ObjectHub/tests/testHubEvent.py:1.1	Thu Aug 22 13:05:24 2002
+++ Zope3/lib/python/Zope/ObjectHub/tests/testHubEvent.py	Thu Oct  3 16:53:23 2002
@@ -53,16 +53,13 @@
         self.event = self.klass(objecthub, self.ruid, self.location)
         
     def testGetLocation(self):
-        "Test getLocation method"
-        self.assertEqual(self.event.getLocation(), self.location)
+        self.assertEqual(self.event.location, self.location)
         
     def testGetRuid(self):
-        "Test getRuid method"
-        self.assertEqual(self.event.getRuid(), self.ruid)
+        self.assertEqual(self.event.hid, self.ruid)
     
     def testGetObject(self):
-        "Test getObject method"
-        self.assertEqual(self.event.getObject(), self.obj)
+        self.assertEqual(self.event.object, self.obj)
     
 class TestObjectRegisteredHubEvent(TestObjectAddedHubEvent):
 


=== Zope3/lib/python/Zope/ObjectHub/tests/testObjectHub.py 1.7 => 1.8 ===
--- Zope3/lib/python/Zope/ObjectHub/tests/testObjectHub.py:1.7	Thu Aug 22 13:05:24 2002
+++ Zope3/lib/python/Zope/ObjectHub/tests/testObjectHub.py	Thu Oct  3 16:53:23 2002
@@ -76,15 +76,15 @@
             location = self._canonical(location)
             testcase.assert_(interface.isImplementedBy(event),
                              'Interface %s' % interface.getName())
-            testcase.assertEqual(event.getLocation(), location)
+            testcase.assertEqual(event.location, location)
             
             if obj is not None:
-                testcase.assertEqual(event.getObject(), obj)
+                testcase.assertEqual(event.object, obj)
             
             # Sometimes, the test won't care about the ruid. In this case,
             # it is passed into the spec as None.
             if ruid is not None:
-                testcase.assertEqual(event.getRuid(), ruid)
+                testcase.assertEqual(event.hid, ruid)
 
         self.events_received = []
 
@@ -96,15 +96,15 @@
     def notify(self, event):
         LoggingSubscriber.notify(self, event)
         if IObjectAddedEvent.isImplementedBy(event):
-            self.hub.register(event.getLocation())                  
+            self.hub.register(event.location)                  
         elif IObjectRemovedEvent.isImplementedBy(event):
             try:
-                ruid = self.hub.lookupRuid(event.getLocation())
+                ruid = self.hub.lookupRuid(event.location)
             except NotFoundError:
                 pass
             else:   
-                location = event.getLocation()
-                obj = event.getObject()
+                location = event.location
+                obj = event.object
                 removeEvent = RuidObjectEvent.ObjectRemovedHubEvent(
                     obj, ruid, location)
                 self.hub.notify(removeEvent)
@@ -173,11 +173,13 @@
         self.object_hub.subscribe(self.subscriber)
 
     def setEvents(self):
-        self.added_event = ObjectAddedEvent(self.location)
-        self.added_new_location_event = ObjectAddedEvent(self.new_location)
-        self.removed_event = ObjectRemovedEvent(self.location, self.obj)
-        self.modified_event = ObjectModifiedEvent(self.location)
-        self.moved_event = ObjectMovedEvent(self.location,
+        self.added_event = ObjectAddedEvent(self.obj, self.location)
+        self.added_new_location_event = ObjectAddedEvent(
+            self.obj, self.new_location)
+        self.removed_event = ObjectRemovedEvent(self.obj, self.location)
+        self.modified_event = ObjectModifiedEvent(self.obj, self.location)
+        self.moved_event = ObjectMovedEvent(self.obj,
+                                            self.location,
                                             self.new_location)
 
 class TestRegistrationEvents(BasicHubTest):