[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - objecthubsetup.py:1.8 test_hookedhubevent.py:1.4 test_hubevent.py:1.3 test_objecthub.py:1.6

Steve Alexander steve@cat-box.net
Wed, 19 Mar 2003 13:05:05 -0500


Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv29463/src/zope/app/services/tests

Modified Files:
	objecthubsetup.py test_hookedhubevent.py test_hubevent.py 
	test_objecthub.py 
Log Message:
Changed the hubIds service / ObjectHub implementation to use unicode
strings for paths, rather than tuples of unicode strings.
This is part of the ongoing work Albert and I are doing to standardize on
unicode strings for paths.



=== Zope3/src/zope/app/services/tests/objecthubsetup.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/services/tests/objecthubsetup.py:1.7	Tue Feb 11 21:17:34 2003
+++ Zope3/src/zope/app/services/tests/objecthubsetup.py	Wed Mar 19 13:05:04 2003
@@ -21,8 +21,8 @@
 from zope.component import getServiceManager, getService
 from zope.app.services.servicenames import HubIds
 from zope.app.services.service import ServiceConfiguration
-from zope.app.traversing import getPhysicalPathString, traverse
-from zope.app.traversing import locationAsTuple
+from zope.app.traversing import traverse
+from zope.app.traversing import locationAsUnicode as canonicalPath
 
 from zope.app.services.hub import ObjectHub
 from zope.app.interfaces.event import IObjectAddedEvent
@@ -58,7 +58,7 @@
                 interface, location = spec
                 obj = None
                 hubid = None
-            location = locationAsTuple(location)
+            location = canonicalPath(location)
             testcase.assert_(interface.isImplementedBy(event),
                              'Interface %s' % interface.getName())
             testcase.assertEqual(event.location, location)


=== Zope3/src/zope/app/services/tests/test_hookedhubevent.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/services/tests/test_hookedhubevent.py:1.3	Mon Dec 30 09:03:17 2002
+++ Zope3/src/zope/app/services/tests/test_hookedhubevent.py	Wed Mar 19 13:05:04 2003
@@ -25,9 +25,8 @@
 from zope.app.services.tests.objecthubsetup import ObjectHubSetup
 from zope.app.services.hub import \
      ObjectRegisteredHubEvent, ObjectUnregisteredHubEvent, \
-     ObjectModifiedHubEvent, ObjectMovedHubEvent, \
-     ObjectRemovedHubEvent
-from zope.app.traversing import getPhysicalPath
+     ObjectModifiedHubEvent, ObjectMovedHubEvent, ObjectRemovedHubEvent
+from zope.app.traversing import getPhysicalPathString as getPath
 
 from zope.component import getService
 
@@ -39,7 +38,7 @@
         ObjectHubSetup.setUp(self)
         self.obj = self.folder1_2_1
         self.hubid = self.object_hub.register(self.obj)
-        self.location = getPhysicalPath(self.obj)
+        self.location = getPath(self.obj)
         self.event = self.klass(self.object_hub,
                                 self.hubid,
                                 self.location,
@@ -67,7 +66,7 @@
         ObjectHubSetup.setUp(self)
         self.obj = self.folder1_2_1
         self.hubid = self.object_hub.register(self.obj)
-        self.location = getPhysicalPath(self.obj)
+        self.location = getPath(self.obj)
         self.event = self.klass(self.object_hub, self.hubid)
 
 class TestObjectUnregisteredHubEvent(AbstractTestHubEvent):
@@ -80,7 +79,7 @@
         ObjectHubSetup.setUp(self)
         self.obj = self.folder1_2_1
         self.hubid = self.object_hub.register(self.obj)
-        self.location = getPhysicalPath(self.obj)
+        self.location = getPath(self.obj)
         self.event = self.klass(self.object_hub, self.hubid, self.location)
 
 class TestObjectModifiedHubEvent(AbstractTestHubEvent):
@@ -93,7 +92,7 @@
         ObjectHubSetup.setUp(self)
         self.obj = self.folder1_2_1
         self.hubid = self.object_hub.register(self.obj)
-        self.location = getPhysicalPath(self.obj)
+        self.location = getPath(self.obj)
         self.event = self.klass(self.object_hub, self.hubid)
 
 class TestObjectMovedHubEvent(AbstractTestHubEvent):
@@ -104,7 +103,7 @@
         ObjectHubSetup.setUp(self)
         self.obj = self.folder1_2_1
         self.hubid = self.object_hub.register(self.obj)
-        self.location = getPhysicalPath(self.obj)
+        self.location = getPath(self.obj)
         self.event = self.klass(self.object_hub,
                                 self.hubid,
                                 self.fromLocation,
@@ -123,7 +122,7 @@
         ObjectHubSetup.setUp(self)
         self.obj = self.folder1_2_1
         self.hubid = self.object_hub.register(self.obj)
-        self.location = getPhysicalPath(self.obj)
+        self.location = getPath(self.obj)
         self.event = self.klass(self.object_hub,
                                 self.hubid,
                                 self.fromLocation)


=== Zope3/src/zope/app/services/tests/test_hubevent.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/services/tests/test_hubevent.py:1.2	Wed Dec 25 09:13:20 2002
+++ Zope3/src/zope/app/services/tests/test_hubevent.py	Wed Mar 19 13:05:04 2003
@@ -40,7 +40,7 @@
 
         raise NotFoundError
 
-    def getLocation(self, ruid):
+    def getPath(self, ruid):
         if ruid==self.ruid:
             return self.location
 


=== Zope3/src/zope/app/services/tests/test_objecthub.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/services/tests/test_objecthub.py:1.5	Mon Dec 30 09:03:17 2002
+++ Zope3/src/zope/app/services/tests/test_objecthub.py	Wed Mar 19 13:05:04 2003
@@ -40,7 +40,8 @@
 from zope.exceptions import NotFoundError
 from types import StringTypes
 
-from zope.app.traversing import locationAsUnicode, locationAsTuple, traverse
+from zope.app.traversing import traverse
+from zope.app.traversing import locationAsUnicode as canonicalPath
 
 # while these tests don't really test much of the placeful aspect of the
 # object hub, they do at least test basic functionality.
@@ -51,7 +52,7 @@
 
 class TransmitHubEventTest(ObjectHubSetup, unittest.TestCase):
     hubid = 23
-    location = locationAsTuple('/foo/bar')
+    location = '/foo/bar'
     obj = object()
     # Don't test the HubEvent base class.
     # See below for testing subclasses / subinterfaces
@@ -62,9 +63,9 @@
         ObjectHubSetup.setUp(self)
         self.setUpLoggingSubscriber()
         self.hub_event = self.klass(self.object_hub,
-                                           self.hubid,
-                                           self.location,
-                                           self.obj)
+                                    self.hubid,
+                                    self.location,
+                                    self.obj)
 
     def testTransmittedEvent(self):
         # Test that the HubEvents are transmitted by the notify method
@@ -91,7 +92,7 @@
         self.setUpLoggingSubscriber()
         self.hub_event = self.klass(
                 self.object_hub, self.hubid,
-                locationAsTuple('/old/location'), self.location, self.obj)
+                '/old/location', self.location, self.obj)
 
 class TransmitObjectRegisteredHubEventTest(TransmitHubEventTest):
     interface = IObjectRegisteredHubEvent
@@ -102,9 +103,9 @@
     klass = ObjectUnregisteredHubEvent
 
 class BasicHubTest(ObjectHubSetup, unittest.TestCase):
-    location = locationAsTuple('/foo/bar')
+    location = '/foo/bar'
     obj = object()
-    new_location = locationAsTuple('/baz/spoo')
+    new_location = '/baz/spoo'
 
     def setUp(self):
         ObjectHubSetup.setUp(self)
@@ -170,39 +171,31 @@
         '/foo/bas',
         '/foo/bas/baz',
         )
-        
+
     def setUp(self):
         ObjectHubSetup.setUp(self)
-        
+
     def testSearchAll(self):
         object_hub = self.object_hub
-        location_hubid = [(locationAsTuple(location),
+        location_hubid = [(location,
                            object_hub.register(location))
                           for location in self.locations]
         location_hubid.sort()
 
-        r = list(object_hub.getRegistrations())
+        r = list(object_hub.iterRegistrations())
         self.assertEqual(r, location_hubid)
 
     def testSearchSome(self):
         object_hub = self.object_hub
-        location_hubid= [(locationAsTuple(location),
+        location_hubid= [(location,
                            object_hub.register(location))
                           for location in self.locations
                           if location.startswith('/foo/bar/')]
         location_hubid.sort()
 
-        r = list(object_hub.getRegistrations('/foo/bar'))
+        r = list(object_hub.iterRegistrations('/foo/bar'))
         self.assertEqual(r, location_hubid)
 
-    def testDetectUnichrFFFF(self):
-        # this is an implementation wrinkle.
-        # the character \uffff is used as a sentinel in searching
-        # so, you're not allowed to register a location with a segment
-        # that starts with that character.
-        self.assertRaises(ValueError,
-                          self.object_hub.register, u'/foo/\uffffstuff')
-
     def testIterObjectRegistrations(self):
         class FakeObject:
             def __init__(self, location):
@@ -213,7 +206,7 @@
                 return self.location == other.location
 
         def fake_object_for_location(location):
-            return FakeObject(locationAsUnicode(location))
+            return FakeObject(canonicalPath(location))
 
         from zope.app.interfaces.traversing import ITraverser
         class DummyTraverser:
@@ -227,7 +220,7 @@
         provideAdapter(None, ITraverser, DummyTraverser)
 
         object_hub = self.object_hub
-        location_hubid_object = [(locationAsTuple(location),
+        location_hubid_object = [(location,
                                   object_hub.register(location),
                                   fake_object_for_location(location)
                                  )
@@ -305,7 +298,7 @@
         # check that hub id is an int
         self.failUnless(isinstance(hubid, int)) # int(hubid)
 
-        location_from_hub = hub.getLocation(hubid)
+        location_from_hub = hub.getPath(hubid)
 
         self.assertEqual(location_from_hub, location)
 
@@ -337,7 +330,7 @@
 
         absent_hubid = 12
 
-        self.assertRaises(NotFoundError, hub.getLocation, absent_hubid)
+        self.assertRaises(NotFoundError, hub.getPath, absent_hubid)
 
         self.subscriber.verifyEventsReceived(self, [])
 
@@ -366,7 +359,7 @@
         hub.notify(removed_event)
 
         self.assertRaises(NotFoundError, hub.getHubId, location)
-        self.assertRaises(NotFoundError, hub.getLocation, hubid)
+        self.assertRaises(NotFoundError, hub.getPath, hubid)
 
         self.subscriber.verifyEventsReceived(self, [
                 (IObjectAddedEvent, location),
@@ -412,13 +405,13 @@
         # check that hubid is an int
         self.failUnless(isinstance(hubid, int)) # int(hubid)
 
-        location_from_hub = hub.getLocation(hubid)
+        location_from_hub = hub.getPath(hubid)
         self.assertEqual(location_from_hub, location)
 
         hub.notify(modified_event)
 
         hubid2 = hub.getHubId(location)
-        location_from_hub2 = hub.getLocation(hubid2)
+        location_from_hub2 = hub.getPath(hubid2)
 
         self.assertEqual(location_from_hub, location_from_hub2)
         self.assertEqual(hubid, hubid2)
@@ -469,7 +462,7 @@
 
         hub.notify(moved_event)
 
-        location_from_hub = hub.getLocation(hubid)
+        location_from_hub = hub.getPath(hubid)
 
         self.assertEqual(location_from_hub, new_location)
         self.assertRaises(NotFoundError, hub.getHubId, location)