[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/tests - testObjectHub.py:1.3

Steve Alexander steve@cat-box.net
Fri, 29 Nov 2002 10:51:04 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/tests
In directory cvs.zope.org:/tmp/cvs-serv28953/lib/python/Zope/App/OFS/Services/ObjectHub/tests

Modified Files:
	testObjectHub.py 
Log Message:
Renamed registrations method to getRegistrations.
Added IHubEventChannel, for use by indexes. This is the basic interface
for filtering event channels that lie between an ObjectHub and an index.
They have a method iterObjectRegistrations for bootstrapping an index with
appropriate, yet filtered, data.


=== Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/tests/testObjectHub.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/tests/testObjectHub.py:1.2	Tue Nov 26 14:02:49 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ObjectHub/tests/testObjectHub.py	Fri Nov 29 10:51:03 2002
@@ -236,7 +236,7 @@
                           for location in self.locations]
         location_hubid.sort()
 
-        r = list(object_hub.registrations())
+        r = list(object_hub.getRegistrations())
         self.assertEqual(r, location_hubid)
 
     def testSearchSome(self):
@@ -247,7 +247,7 @@
                           if location.startswith('/foo/bar/')]
         location_hubid.sort()
 
-        r = list(object_hub.registrations('/foo/bar'))
+        r = list(object_hub.getRegistrations('/foo/bar'))
         self.assertEqual(r, location_hubid)
 
     def testDetectUnichrFFFF(self):
@@ -257,6 +257,36 @@
         # that starts with that character.
         self.assertRaises(ValueError,
                           self.object_hub.register, u'/foo/\uffffstuff')
+
+    def testIterObjectRegistrations(self):
+        from Zope.App.Traversing import locationAsUnicode
+        def fake_object_for_location(location):
+            return 'object at %s' % locationAsUnicode(location)
+
+        from Zope.App.Traversing.ITraverser import ITraverser
+        class DummyTraverser:
+            __implements__ = ITraverser
+            def __init__(self, context):
+                pass
+            def traverse(self, location):
+                return fake_object_for_location(location)
+
+        from Zope.ComponentArchitecture.GlobalAdapterService\
+             import provideAdapter
+        provideAdapter(None, ITraverser, DummyTraverser)
+
+        object_hub = self.object_hub
+        
+        location_hubid_object = [(locationAsTuple(location),
+                                  object_hub.register(location),
+                                  fake_object_for_location(location)
+                                 )
+                                 for location in self.locations]
+        location_hubid_object.sort()
+
+        r = [loc_id for loc_id in object_hub.iterObjectRegistrations()]
+        r.sort()
+        self.assertEqual(r, location_hubid_object)
 
 class TestNoRegistration(BasicHubTest):