[Zope-Checkins] CVS: Zope3/lib/python/Zope/Event/tests - testEventService.py:1.1.2.2
Steve Alexander
steve@cat-box.net
Sat, 23 Feb 2002 07:00:41 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Event/tests
In directory cvs.zope.org:/tmp/cvs-serv24487/tests
Modified Files:
Tag: Zope-3x-branch
testEventService.py
Log Message:
There's now a filesystem based event service.
=== Zope3/lib/python/Zope/Event/tests/testEventService.py 1.1.2.1 => 1.1.2.2 ===
import unittest, sys
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
from Zope.Event.IObjectEvent import IObjectEvent
from Zope.Event.IObjectEvent import IObjectAddedEvent
@@ -26,6 +27,7 @@
from Zope.Event.ObjectEvent import ObjectAddedEvent
from Zope.Event.EventService import EventService
from Zope.Exceptions import NotFoundError
+from Zope import Event
class DummySubscriber:
@@ -52,7 +54,7 @@
__implements__ = IObjectEvent
class TestEventService(unittest.TestCase):
-
+
def setUp(self):
self.service = EventService()
self.event = ObjectAddedEvent('/foo')
@@ -61,7 +63,7 @@
def testSubscribe1(self):
"Test subscribe method with one parameter"
self.service.subscribe(self.subscriber)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 1)
def testSubscribe2(self):
@@ -70,7 +72,7 @@
self.subscriber,
event_types=[IObjectAddedEvent]
)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 1)
def testSubscribe3(self):
@@ -80,7 +82,7 @@
event_types=[IObjectAddedEvent],
filter=DummyFilter()
)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 1)
def testSubscribe4(self):
@@ -92,7 +94,7 @@
event_types=[IObjectAddedEvent],
filter=DummyFilter(0)
)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 0)
def testSubscribe5(self):
@@ -104,25 +106,25 @@
event_types=[IObjectModifiedEvent],
filter=DummyFilter()
)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 0)
def testSubscribe6(self):
"""Test subscribe method where the event type
registered is a generalised interface of the
- event passed to the 'publish' method.
+ event passed to the 'publishEvent' method.
"""
self.service.subscribe(
self.subscriber,
event_types=[IObjectEvent]
)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 1)
def testSubscribe7(self):
"""Test subscribe method where one of the
event types registered is not interested in
- the published event.
+ the publishEvented event.
"""
self.service.subscribe(
self.subscriber,
@@ -132,7 +134,7 @@
self.subscriber,
event_types=[IObjectAddedEvent]
)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 1)
def testSubscribe8(self):
@@ -154,17 +156,17 @@
event_types=[IObjectAddedEvent],
filter=DummyFilter(0)
)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 2)
def testUnsubscribe1(self):
"Test unsubscribe method"
subscriber = self.subscriber
self.service.subscribe(subscriber)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 1)
self.service.unsubscribe(subscriber)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 1)
def testUnsubscribe2(self):
@@ -174,16 +176,16 @@
self.service.unsubscribe,
subscriber)
- def testPublish1(self):
- "Test publish method"
+ def testpublishEvent1(self):
+ "Test publishEvent method"
subscriber = self.subscriber
self.service.subscribe(subscriber)
self.assertEqual(self.subscriber.notified, 0)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 1)
- def testPublish2(self):
- """Test publish method where subscriber has been
+ def testpublishEvent2(self):
+ """Test publishEvent method where subscriber has been
subscribed twice, with a more generalised
version of the initially subscribed interface
in the second subscription.
@@ -197,11 +199,11 @@
self.subscriber,
event_types=[IObjectAddedEvent],
)
- self.service.publish(self.event)
+ self.service.publishEvent(self.event)
self.assertEqual(self.subscriber.notified, 2)
- def testPublish3(self):
- """Test publish method where subscriber has been
+ def testpublishEvent3(self):
+ """Test publishEvent method where subscriber has been
to two interfaces and a single event implements both
of those interfaces.
"""
@@ -210,11 +212,11 @@
self.subscriber,
event_types=[IObjectRemovedEvent,IObjectAddedEvent],
)
- self.service.publish(DummyEvent())
+ self.service.publishEvent(DummyEvent())
self.assertEqual(self.subscriber.notified, 2)
- def testPublish4(self):
- """Test publish method to make sure that we don't
+ def testpublishEvent4(self):
+ """Test publishEvent method to make sure that we don't
'leak registrations up' sez Jim.
"""
subscriber = self.subscriber
@@ -226,12 +228,20 @@
self.subscriber,
event_types=[IObjectAddedEvent],
)
- self.service.publish(ObjectEvent())
+ self.service.publishEvent(ObjectEvent())
self.assertEqual(self.subscriber.notified, 1)
+class TestFSEventService(CleanUp, TestEventService):
+
+ def setUp(self):
+ self.service = Event
+ self.event = ObjectAddedEvent('/foo')
+ self.subscriber = DummySubscriber()
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestEventService),
+ unittest.makeSuite(TestFSEventService),
))
if __name__=='__main__':