[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests -
test_eventservice.py:1.28 test_objecthub.py:1.13
Jim Fulton
jim at zope.com
Sun Sep 21 13:33:16 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv15178/src/zope/app/services/tests
Modified Files:
test_eventservice.py test_objecthub.py
Log Message:
No-longer use context wrappers.
Refactored events and notification framework. Object events no longer
have locations. Location-relevent events now include parent and name
information. Add and remove events extend move events.
Changed to use __setitem__ rather than setObject
=== Zope3/src/zope/app/services/tests/test_eventservice.py 1.27 => 1.28 ===
--- Zope3/src/zope/app/services/tests/test_eventservice.py:1.27 Sat Jun 21 17:22:13 2003
+++ Zope3/src/zope/app/services/tests/test_eventservice.py Sun Sep 21 13:33:15 2003
@@ -28,18 +28,34 @@
from zope.app.event import publish
from zope.app.event.tests.subscriber import DummySubscriber, DummyFilter
from zope.app.interfaces.event import IObjectEvent, IObjectModifiedEvent
-from zope.app.interfaces.event import IObjectRemovedEvent, IObjectAddedEvent
+from zope.app.interfaces.container import IObjectAddedEvent
+from zope.app.interfaces.container import IObjectRemovedEvent
from zope.app.interfaces.event import ISubscriber
-from zope.app.event.objectevent import ObjectAddedEvent, ObjectModifiedEvent
+from zope.app.container.contained import ObjectAddedEvent
+from zope.app.event.objectevent import ObjectModifiedEvent
from zope.app.interfaces.event import IEvent, ISubscribingAware
from zope.app.interfaces.services.registration import RegisteredStatus
-from zope.app.context import ContextWrapper
from zope.app.services.tests.eventsetup import EventSetup
from zope.component.tests.components import RecordingAdapter
from zope.component.adapter import provideAdapter
from zope.app.interfaces.services.service import ISimpleService
from zope.app.services.event import EventService
from zope.app.tests import setup
+from zope.app.container.contained import Contained
+from zope.app.interfaces.traversing import IContainmentRoot
+import zope.interface
+
+class Folder(Contained):
+ pass
+
+root = Folder()
+zope.interface.directlyProvides(root, IContainmentRoot)
+foo = Folder()
+foo.__parent__ = root
+foo.__name__ = 'foo'
+
+
+
class UnpromotingEventService(EventService):
@@ -127,21 +143,12 @@
setup.addService(sm, EventSubscription, events, suffix='s')
def _createSubscribers(self):
- self.rootFolder.setObject("rootFolderSubscriber", DummySubscriber())
- self.rootFolderSubscriber = ContextWrapper(
- self.rootFolder["rootFolderSubscriber"],
- self.rootFolder,
- name="rootFolderSubscriber")
- self.folder1.setObject("folder1Subscriber", DummySubscriber())
- self.folder1Subscriber = ContextWrapper(
- self.folder1["folder1Subscriber"],
- self.folder1,
- name="folder1Subscriber")
- self.folder1_1.setObject("folder1_1Subscriber", DummySubscriber())
- self.folder1_1Subscriber = ContextWrapper(
- self.folder1_1["folder1_1Subscriber"],
- self.folder1_1,
- name="folder1_1Subscriber")
+ self.rootFolder["rootFolderSubscriber"] = DummySubscriber()
+ self.rootFolderSubscriber = self.rootFolder["rootFolderSubscriber"]
+ self.folder1["folder1Subscriber"] = DummySubscriber()
+ self.folder1Subscriber = self.folder1["folder1Subscriber"]
+ self.folder1_1["folder1_1Subscriber"] = DummySubscriber()
+ self.folder1_1Subscriber = self.folder1_1["folder1_1Subscriber"]
def _createHubIdSubscribers(self):
self._createSubscribers()
@@ -171,7 +178,7 @@
self.assertEqual(root, getPath(self.rootFolderSubscriber))
self.assertEqual(folder1, getPath(self.folder1Subscriber))
self.assertEqual(folder1_1, getPath(self.folder1_1Subscriber))
- publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
@@ -184,7 +191,7 @@
unsubscribe(folder1_1Path,
event_type=IObjectAddedEvent,
context=self.folder1_1)
- publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
@@ -213,7 +220,7 @@
('/folder1/folder1_1/folder1_1Subscriber',
self.folder1_1Subscriber)
)
- publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
@@ -228,7 +235,7 @@
unsubscribe(2,
event_type=IObjectAddedEvent,
context=self.folder1_1)
- publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1, ObjectAddedEvent(None, 'fauxparent', 'foo'))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
@@ -251,7 +258,7 @@
folder1Subscriber = self.folder1['folder1Subscriber']
del self.folder1['folder1Subscriber']
- publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
self.assertEqual(self.folder1Subscriber.notified, 0)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
@@ -259,14 +266,14 @@
# Now, put folder1Subscriber back. This incidentally fires off a
# ObjectAddedEvent, since self.folder1 is decorated with a context
# decorator.
- self.folder1.setObject('folder1Subscriber', folder1Subscriber)
+ self.folder1['folder1Subscriber'] = folder1Subscriber
self.assertEqual(self.rootFolderSubscriber.notified, 2)
self.assertEqual(self.folder1Subscriber.notified, 0)
self.assertEqual(self.folder1_1Subscriber.notified, 2)
# folder1Subscriber should not be notified now, because it was removed
# as a bad subscriber.
- publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 3)
self.assertEqual(self.folder1Subscriber.notified, 0)
self.assertEqual(self.folder1_1Subscriber.notified, 3)
@@ -296,7 +303,7 @@
folder1_1Path,
event_type=IObjectAddedEvent,
context=self.folder1_1))
- publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
@@ -310,7 +317,7 @@
unsubscribe(folder1_1Path,
event_type=IObjectAddedEvent,
context=self.folder1_1)
- publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
@@ -343,7 +350,7 @@
('/folder1/folder1_1/folder1_1Subscriber',
self.folder1_1Subscriber)
)
- publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
@@ -358,7 +365,7 @@
unsubscribe(2,
event_type=IObjectAddedEvent,
context=self.folder1_1)
- publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
@@ -486,7 +493,7 @@
def _testSubscribe1(self):
# Test subscribe method with one parameter
subscribe(self.rootFolderSubscriber)
- publish(self.rootFolder, ObjectAddedEvent(None, '/foo'))
+ publish(self.rootFolder, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
def testPathSubscribe1(self):
@@ -503,7 +510,7 @@
self.rootFolderSubscriber,
event_type=IObjectAddedEvent
)
- publish(self.folder1_1_1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1_1_1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
def testPathSubscribe2(self):
@@ -521,7 +528,7 @@
event_type=IObjectAddedEvent,
filter=DummyFilter()
)
- publish(self.folder1_1_1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1_1_1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
def testPathSubscribe3(self):
@@ -540,7 +547,7 @@
event_type=IObjectAddedEvent,
filter=DummyFilter(0)
)
- publish(self.folder1_1_1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1_1_1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 0)
def testPathSubscribe4(self):
@@ -559,7 +566,7 @@
event_type=IObjectModifiedEvent,
filter=DummyFilter()
)
- publish(self.folder1_1_1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1_1_1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 0)
def testPathSubscribe5(self):
@@ -577,7 +584,7 @@
self.rootFolderSubscriber,
event_type=IObjectEvent
)
- publish(self.folder1_1_1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1_1_1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
def testPathSubscribe6(self):
@@ -599,7 +606,7 @@
self.rootFolderSubscriber,
event_type=IObjectAddedEvent
)
- publish(self.folder1_1_1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1_1_1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
def testPathSubscribe7(self):
@@ -626,7 +633,7 @@
event_type=IObjectAddedEvent,
filter=DummyFilter(0)
)
- publish(self.folder1_1_1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1_1_1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 2)
def testPathSubscribe8(self):
@@ -642,12 +649,12 @@
subscribe(
self.rootFolderSubscriber
)
- publish(self.folder1_1_1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1_1_1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
unsubscribeAll(
self.rootFolderSubscriber
)
- publish(self.folder1_1_1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1_1_1, ObjectAddedEvent(foo))
self.assertEqual(self.rootFolderSubscriber.notified, 1)
def testPathUnsubscribe1(self):
@@ -679,8 +686,8 @@
subscriber = self.rootFolderSubscriber
subscriber2 = self.folder1Subscriber
filter = DummyFilter()
- event = ObjectAddedEvent(None, '/foo')
- event2 = ObjectModifiedEvent(None, '/foo')
+ event = ObjectAddedEvent(foo)
+ event2 = ObjectModifiedEvent(None)
subscribe(
subscriber)
subscribe(
@@ -747,7 +754,7 @@
subscriber = self.rootFolderSubscriber
subscribe(subscriber)
self.assertEqual(subscriber.notified, 0)
- publish(self.folder1_1_1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1_1_1, ObjectAddedEvent(foo))
self.assertEqual(subscriber.notified, 1)
def testPathPublish1(self):
@@ -771,7 +778,7 @@
subscriber,
event_type=IObjectAddedEvent,
)
- publish(self.folder1_1_1, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder1_1_1, ObjectAddedEvent(foo))
self.assertEqual(subscriber.notified, 2)
def testPathPublish2(self):
@@ -829,11 +836,8 @@
self._testpublish4()
def _createAlternateService(self, service):
- self.folder2.setObject("folder2Subscriber", DummySubscriber())
- self.folder2Subscriber = ContextWrapper(
- self.folder2["folder2Subscriber"],
- self.folder2,
- name="folder2Subscriber")
+ self.folder2["folder2Subscriber"] = DummySubscriber()
+ self.folder2Subscriber = self.folder2["folder2Subscriber"]
sm = self.makeSite('folder2')
setup.addService(sm, EventPublication, service);
@@ -853,7 +857,7 @@
# with the appropriate isPromotableEvent setting
self._createHubIdSubscribers()
self._createAlternateService(UnpromotingEventService())
- publish(self.folder2, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder2, ObjectAddedEvent(foo))
self.assertEqual(self.folder2Subscriber.notified, 1)
self.assertEqual(self.rootFolderSubscriber.notified, 0)
@@ -862,7 +866,7 @@
# the appropriate isPromotableEvent setting
self._createHubIdSubscribers()
self._createAlternateService(EventService())
- publish(self.folder2, ObjectAddedEvent(None, '/foo'))
+ publish(self.folder2, ObjectAddedEvent(foo))
self.assertEqual(self.folder2Subscriber.notified, 1)
self.assertEqual(self.rootFolderSubscriber.notified, 1)
@@ -887,14 +891,14 @@
sm = traverse(self.rootFolder, "folder1/++etc++site")
registration = sm.queryRegistrations(EventPublication).active()
registration.status = RegisteredStatus
- publish(self.rootFolder, ObjectAddedEvent(None, '/foo'))
+ publish(self.rootFolder, ObjectAddedEvent(foo))
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
registration = sm.queryRegistrations(EventSubscription).active()
registration.status = RegisteredStatus
- publish(self.rootFolder, ObjectAddedEvent(None, '/foo'))
+ publish(self.rootFolder, ObjectAddedEvent(foo))
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 2)
@@ -904,7 +908,7 @@
sv.subscribeOnBind = 0
self._createHubIdSubscribers()
self._createAlternateService(sv)
- publish(self.rootFolder, ObjectAddedEvent(None, '/foo'))
+ publish(self.rootFolder, ObjectAddedEvent(foo))
self.assertEqual(self.folder2Subscriber.notified, 0)
self.assertEqual(self.rootFolderSubscriber.notified, 1)
@@ -921,13 +925,8 @@
provideAdapter(IHasSubscribingAwareAdapter,
ISubscribingAware,
adapter)
- self.rootFolder.setObject(
- "mySubscriber",
- HasSubscribingAwareAdapter())
- self.mySubscriber = ContextWrapper(
- self.rootFolder["mySubscriber"],
- self.rootFolder,
- name="mySubscriber")
+ self.rootFolder["mySubscriber"] = HasSubscribingAwareAdapter()
+ self.mySubscriber = self.rootFolder["mySubscriber"]
filter = DummyFilter()
subscribe(
self.mySubscriber,
=== Zope3/src/zope/app/services/tests/test_objecthub.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/services/tests/test_objecthub.py:1.12 Thu Aug 7 11:32:47 2003
+++ Zope3/src/zope/app/services/tests/test_objecthub.py Sun Sep 21 13:33:15 2003
@@ -18,31 +18,39 @@
"""
import unittest
+from zope.app import zapi
from zope.app.services.tests.objecthubsetup import ObjectHubSetup
-from zope.app.interfaces.event\
- import IObjectAddedEvent, IObjectRemovedEvent, IObjectModifiedEvent,\
- IObjectMovedEvent
-from zope.app.event.objectevent\
- import ObjectAddedEvent, ObjectModifiedEvent, ObjectRemovedEvent,\
- ObjectMovedEvent, ObjectCreatedEvent
+from zope.app.interfaces.event import IObjectModifiedEvent
+from zope.app.interfaces.container import IObjectAddedEvent
+from zope.app.interfaces.container import IObjectRemovedEvent
+from zope.app.interfaces.container import IObjectMovedEvent
+
+from zope.app.container.contained import ObjectAddedEvent, ObjectRemovedEvent
+from zope.app.container.contained import ObjectMovedEvent
+from zope.app.event.objectevent import ObjectModifiedEvent, ObjectCreatedEvent
+
from zope.app.interfaces.services.hub import ObjectHubError
-from zope.app.interfaces.services.hub import \
- IObjectRemovedHubEvent, IObjectModifiedHubEvent, \
- IObjectMovedHubEvent, IObjectRegisteredHubEvent, \
- IObjectUnregisteredHubEvent
-
-from zope.app.services.hub \
- import ObjectModifiedHubEvent, ObjectRemovedHubEvent, \
- ObjectMovedHubEvent, ObjectRegisteredHubEvent, \
- ObjectUnregisteredHubEvent
+from zope.app.interfaces.services.hub import IObjectRemovedHubEvent
+from zope.app.interfaces.services.hub import IObjectModifiedHubEvent
+from zope.app.interfaces.services.hub import IObjectMovedHubEvent
+from zope.app.interfaces.services.hub import IObjectRegisteredHubEvent
+from zope.app.interfaces.services.hub import IObjectUnregisteredHubEvent
+
+from zope.app.services.hub import ObjectModifiedHubEvent, ObjectRemovedHubEvent
+from zope.app.services.hub import ObjectMovedHubEvent, ObjectRegisteredHubEvent
+from zope.app.services.hub import ObjectUnregisteredHubEvent
+
+from zope.app.interfaces.traversing import IContainmentRoot
+from zope.app.location import Location
from zope.exceptions import NotFoundError
from zope.app.traversing import canonicalPath, traverse
-from zope.context import Wrapper
-from zope.interface import implements
+from zope.interface import implements, directlyProvides
+
+from zope.app.container.contained import Contained
# while these tests don't really test much of the placeful aspect of the
# object hub, they do at least test basic functionality.
@@ -53,8 +61,7 @@
class TransmitHubEventTest(ObjectHubSetup, unittest.TestCase):
hubid = 23
- location = '/foo/bar'
- obj = object()
+ location = '/folder1/folder1_1'
# Don't test the HubEvent base class.
# See below for testing subclasses / subinterfaces
# klass = HubEvent
@@ -63,6 +70,8 @@
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpLoggingSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
+
self.hub_event = self.klass(self.object_hub,
self.hubid,
self.location,
@@ -91,6 +100,7 @@
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpLoggingSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.hub_event = self.klass(
self.object_hub, self.hubid,
'/old/location', self.location, self.obj)
@@ -103,26 +113,32 @@
interface = IObjectUnregisteredHubEvent
klass = ObjectUnregisteredHubEvent
+class Folder(Location):
+ pass
+
class BasicHubTest(ObjectHubSetup, unittest.TestCase):
- location = '/foo/bar'
- obj = object()
- new_location = '/baz/spoo'
+ location = '/folder1/folder1_1'
+ new_location = '/folder2/folder2_1'
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpLoggingSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.setEvents()
def setEvents(self):
- self.created_event = ObjectCreatedEvent(object())
- 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)
+ obj = self.obj
+ self.created_event = ObjectCreatedEvent(obj)
+ self.added_event = ObjectAddedEvent(obj)
+ newobj = zapi.traverse(self.rootFolder, self.new_location)
+ self.added_new_location_event = ObjectAddedEvent(newobj)
+ self.removed_event = ObjectRemovedEvent(obj)
+ self.modified_event = ObjectModifiedEvent(obj)
+ self.moved_event = ObjectMovedEvent(
+ obj,
+ obj.__parent__, obj.__name__,
+ newobj.__parent__, newobj.__name__,
+ )
class TestRegistrationEvents(BasicHubTest):
def testRegistration(self):
@@ -285,6 +301,7 @@
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpRegistrationSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.setEvents()
def testLookingUpLocation(self):
@@ -341,6 +358,7 @@
class TestObjectRemovedEvent(BasicHubTest):
def setUp(self):
ObjectHubSetup.setUp(self)
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.setUpRegistrationSubscriber()
self.setEvents()
@@ -393,6 +411,7 @@
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpRegistrationSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.setEvents()
def testModifiedLocation(self):
@@ -450,6 +469,7 @@
def setUp(self):
ObjectHubSetup.setUp(self)
self.setUpRegistrationSubscriber()
+ self.obj = zapi.traverse(self.rootFolder, self.location)
self.setEvents()
def testMovedLocation(self):
@@ -462,6 +482,16 @@
hub.notify(added_event)
hubid = hub.getHubId(location)
+
+ self.subscriber.verifyEventsReceived(self, [
+ (IObjectAddedEvent, location),
+ (IObjectRegisteredHubEvent, hubid, location),
+ ])
+
+ # simulate moving the object
+ self.obj.__parent__ = zapi.traverse(self.rootFolder, "folder2")
+ self.obj.__name__ = "folder2_1"
+
hub.notify(moved_event)
location_from_hub = hub.getPath(hubid)
@@ -473,8 +503,6 @@
self.assertEqual(hubid2, hubid)
self.subscriber.verifyEventsReceived(self, [
- (IObjectAddedEvent, location),
- (IObjectRegisteredHubEvent, hubid, location),
(IObjectMovedEvent, new_location),
(IObjectMovedHubEvent, hubid, new_location)
])
@@ -495,6 +523,10 @@
self.assertRaises(NotFoundError, hub.getHubId, location)
self.assertRaises(NotFoundError, hub.getHubId, new_location)
+ # simulate moving the object
+ self.obj.__parent__ = zapi.traverse(self.rootFolder, "folder2")
+ self.obj.__name__ = "folder2_1"
+
self.subscriber.verifyEventsReceived(self, [
(IObjectMovedEvent, new_location),
])
@@ -512,13 +544,20 @@
hub.notify(added_event)
hub.notify(added_event2)
- self.assertRaises(ObjectHubError, hub.notify, moved_event)
-
self.subscriber.verifyEventsReceived(self, [
(IObjectAddedEvent, location),
(IObjectRegisteredHubEvent, None, location),
(IObjectAddedEvent, new_location),
(IObjectRegisteredHubEvent, None, new_location),
+ ])
+
+ # simulate moving the object
+ self.obj.__parent__ = zapi.traverse(self.rootFolder, "folder2")
+ self.obj.__name__ = "folder2_1"
+
+ self.assertRaises(ObjectHubError, hub.notify, moved_event)
+
+ self.subscriber.verifyEventsReceived(self, [
(IObjectMovedEvent, new_location),
])
@@ -546,11 +585,11 @@
def setUp(self):
ObjectHubSetup.setUp(self)
- self.rootFolder.setObject('deleted', self.obj)
- self.deleted_obj = Wrapper(object(), self.rootFolder, name='deleted')
+ self.rootFolder['deleted'] = Contained()
+ self.deleted_obj = self.rootFolder['deleted']
self.deleted_path = '/deleted'
- self.rootFolder.setObject('valid', self.obj)
- self.valid_obj = Wrapper(object(), self.rootFolder, name='valid')
+ self.rootFolder['valid'] = Contained()
+ self.valid_obj = self.rootFolder['valid']
self.valid_path = '/valid'
# register the objects
@@ -582,7 +621,7 @@
def testGetHubId(self):
# no lazy unregistration
self.assert_(self.object_hub.getHubId(self.deleted_path))
- self.assert_(self.object_hub.getHubId(self.deleted_obj))
+ #self.assert_(self.object_hub.getHubId(self.deleted_obj))
self.assertEqual(self.object_hub.numRegistrations(), 2)
@@ -605,14 +644,19 @@
# for valid paths, so it doesn't make sense to unregister
self.assertRaises(ObjectHubError, self.object_hub.register,
self.deleted_path)
- self.assertRaises(ObjectHubError, self.object_hub.register,
- self.deleted_obj)
+ # The deleted object now (after parentgeddon) has no path, so
+ # this assertion no longer makes sense.
+## self.assertRaises(ObjectHubError, self.object_hub.register,
+## self.deleted_obj)
- def testUnregister(self):
- # no lazy unregistration
- self.object_hub.unregister(self.deleted_obj)
- self.assertEqual(self.object_hub.numRegistrations(), 1)
+
+ # We can't unregister an object *after* it has been deleted, because
+ # it has no location at that point.
+## def testUnregister(self):
+## # no lazy unregistration
+## self.object_hub.unregister(self.deleted_obj)
+## self.assertEqual(self.object_hub.numRegistrations(), 1)
def numRegistrations(self):
More information about the Zope3-Checkins
mailing list