[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - test_eventservice.py:1.15
Steve Alexander
steve@cat-box.net
Sun, 16 Mar 2003 10:44:06 -0500
Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv30157/src/zope/app/services/tests
Modified Files:
test_eventservice.py
Log Message:
Reinstated the code that removes bad subscribers from an event channel's
subscriptions, along with a unit test for this code path.
This is the code Guido commented out, as it was broken, with no unit test.
http://mail.zope.org/pipermail/zope3-checkins/2003-March/006968.html
=== Zope3/src/zope/app/services/tests/test_eventservice.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/services/tests/test_eventservice.py:1.14 Tue Mar 11 11:11:31 2003
+++ Zope3/src/zope/app/services/tests/test_eventservice.py Sun Mar 16 10:44:05 2003
@@ -239,6 +239,44 @@
self.assertEqual(self.folder1Subscriber.notified, 1)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
+ def testBadSubscriber(self):
+ self._createSubscribers()
+ root = subscribe(
+ self.rootFolderSubscriber,
+ event_type=IObjectAddedEvent
+ )
+ folder1 = subscribe(self.folder1Subscriber,
+ event_type=IObjectAddedEvent)
+ folder1_1 = subscribe(self.folder1_1Subscriber,
+ event_type=IObjectAddedEvent)
+ self.assertEqual(
+ root,
+ getPhysicalPathString(self.rootFolderSubscriber))
+ self.assertEqual(
+ folder1,
+ getPhysicalPathString(self.folder1Subscriber))
+ self.assertEqual(
+ folder1_1,
+ getPhysicalPathString(self.folder1_1Subscriber))
+ # Remove folder1Subscriber, so that the event service will not
+ # be able to notify it.
+ folder1Subscriber = self.folder1['folder1Subscriber']
+ del self.folder1['folder1Subscriber']
+
+ publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ self.assertEqual(self.rootFolderSubscriber.notified, 1)
+ self.assertEqual(self.folder1Subscriber.notified, 0)
+ self.assertEqual(self.folder1_1Subscriber.notified, 1)
+
+ # Now, put folder1Subscriber back. It should not be notified
+ # now, because it was removed as a bad subscriber.
+ self.folder1.setObject('folder1Subscriber', folder1Subscriber)
+
+ publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ self.assertEqual(self.rootFolderSubscriber.notified, 2)
+ self.assertEqual(self.folder1Subscriber.notified, 0)
+ self.assertEqual(self.folder1_1Subscriber.notified, 2)
+
def testByPathExplicit(self):
# test complex interaction, with hubids available but explicitly
# using paths