[Zope3-checkins] CVS: Zope3/src/zope/app/event/tests -
test_directives.py:1.11 test_eventpublisher.py:1.5
test_logger.py:1.11 test_objectevent.py:1.4
Jim Fulton
jim at zope.com
Sun Sep 21 13:32:10 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/event/tests
In directory cvs.zope.org:/tmp/cvs-serv13990/src/zope/app/event/tests
Modified Files:
test_directives.py test_eventpublisher.py test_logger.py
test_objectevent.py
Log Message:
Moved the location-relevent events to container.contained.
location-relevent events are now passed separate parent and name,
rather than location (path) arguments.
=== Zope3/src/zope/app/event/tests/test_directives.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/event/tests/test_directives.py:1.10 Sun Aug 3 17:56:13 2003
+++ Zope3/src/zope/app/event/tests/test_directives.py Sun Sep 21 13:32:09 2003
@@ -25,8 +25,8 @@
from zope.exceptions import NotFoundError
from zope.app.event import globalUnsubscribe, publish
-from zope.app.event.objectevent import ObjectAddedEvent
-from zope.app.event.objectevent import ObjectRemovedEvent
+from zope.app.container.contained import ObjectAddedEvent
+from zope.app.container.contained import ObjectRemovedEvent
from zope.app.event.objectevent import ObjectModifiedEvent
from zope.app.event.tests.test_eventpublisher import DummyEvent
from zope.component.tests.placelesssetup import PlacelessSetup
@@ -56,17 +56,18 @@
<test:subscribe
subscriber="zope.app.event.tests.subscriber.subscriber"
event_types=
- "zope.app.interfaces.event.IObjectAddedEvent
- zope.app.interfaces.event.IObjectRemovedEvent"
+ "zope.app.interfaces.container.IObjectAddedEvent
+ zope.app.interfaces.container.IObjectRemovedEvent"
filter="zope.app.event.tests.subscriber.filter" />
</configure>'''
))
- publish(None, ObjectAddedEvent(None, 'foo'))
+ parent= object()
+ publish(None, ObjectAddedEvent(None, parent, 'foo'))
self.assertEqual(subscriber.notified, 1)
- publish(None, ObjectRemovedEvent(object(), 'foo'))
+ publish(None, ObjectRemovedEvent(object(), parent, 'foo'))
self.assertEqual(subscriber.notified, 2)
- publish(None, ObjectModifiedEvent(None, 'foo'))
+ publish(None, ObjectModifiedEvent(None))
self.assertEqual(subscriber.notified, 2) # NB: no increase ;-)
publish(None, DummyEvent())
self.assertEqual(subscriber.notified, 4) # NB: increased by 2 ;-)
=== Zope3/src/zope/app/event/tests/test_eventpublisher.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/event/tests/test_eventpublisher.py:1.4 Sat Jun 7 02:37:25 2003
+++ Zope3/src/zope/app/event/tests/test_eventpublisher.py Sun Sep 21 13:32:09 2003
@@ -19,10 +19,12 @@
import unittest
-from zope.app.interfaces.event import IObjectEvent, IObjectAddedEvent
-from zope.app.interfaces.event import IObjectRemovedEvent
+from zope.app.interfaces.event import IObjectEvent
+from zope.app.interfaces.container import IObjectAddedEvent
+from zope.app.interfaces.container import IObjectRemovedEvent
from zope.app.interfaces.event import IObjectModifiedEvent
-from zope.app.event.objectevent import ObjectAddedEvent, ObjectModifiedEvent
+from zope.app.event.objectevent import ObjectModifiedEvent
+from zope.app.container.contained import ObjectAddedEvent
from zope.app.event.globalservice import GlobalEventPublisher
from zope.exceptions import NotFoundError
from zope.app.interfaces.event import IEvent
@@ -44,7 +46,8 @@
def setUp(self):
PlacelessSetup.setUp(self)
self.service = GlobalEventPublisher()
- self.event = ObjectAddedEvent(None, '/foo')
+ parent = object()
+ self.event = ObjectAddedEvent(None, parent, 'foo')
self.subscriber = DummySubscriber()
def testSubscribe1(self):
@@ -162,7 +165,7 @@
# Test selective unsubscribe
subscriber2=DummySubscriber()
filter=DummyFilter()
- event2=ObjectModifiedEvent(None, '/foo')
+ event2=ObjectModifiedEvent(None)
self.service.globalSubscribe(
self.subscriber)
self.service.globalSubscribe(
=== Zope3/src/zope/app/event/tests/test_logger.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/event/tests/test_logger.py:1.10 Mon Jun 30 16:48:39 2003
+++ Zope3/src/zope/app/event/tests/test_logger.py Sun Sep 21 13:32:09 2003
@@ -23,7 +23,7 @@
from zope.app.services.servicenames import EventPublication
from zope.app.event import globalSubscribe, globalUnsubscribe, publish
-from zope.app.event.objectevent import ObjectAddedEvent
+from zope.app.container.contained import ObjectAddedEvent
from zope.app.event.globalservice import Logger
class DopeyHandler(logging.Handler):
@@ -56,7 +56,7 @@
# register a logger
globalSubscribe(self.eventlogger)
# send an event
- publish(None, ObjectAddedEvent(None, 'foo'))
+ publish(None, ObjectAddedEvent(None, "parent", 'foo'))
def tearDown(self):
globalUnsubscribe(self.eventlogger)
@@ -72,10 +72,16 @@
result = results[0]
self.assertEqual(result.name, "Event.Logger")
self.assertEqual(result.levelno, logging.INFO)
- self.assertEqual(result.getMessage(),
- "zope.app.event.objectevent.ObjectAddedEvent: "
- "[('_ObjectEvent__location', 'foo'), "
- "('object', None)]\n")
+ self.assertEqual(
+ result.getMessage(),
+ "zope.app.container.contained.ObjectAddedEvent: ["
+ "('newName', 'foo'),\n "
+ "('newParent', 'parent'),\n "
+ "('object', None),\n "
+ "('oldName', None),\n "
+ "('oldParent', None)"
+ "]\n"
+ )
self.assertEqual(result.exc_info, None)
class TestLogger2(TestLogger1):
@@ -89,10 +95,16 @@
result = results[0]
self.assertEqual(result.name, "Event.Logger")
self.assertEqual(result.levelno, logging.CRITICAL)
- self.assertEqual(result.getMessage(),
- "zope.app.event.objectevent.ObjectAddedEvent: "
- "[('_ObjectEvent__location', 'foo'), "
- "('object', None)]\n")
+ self.assertEqual(
+ result.getMessage(),
+ "zope.app.container.contained.ObjectAddedEvent: ["
+ "('newName', 'foo'),\n "
+ "('newParent', 'parent'),\n "
+ "('object', None),\n "
+ "('oldName', None),\n "
+ "('oldParent', None)"
+ "]\n"
+ )
self.assertEqual(result.exc_info, None)
def test_suite():
=== Zope3/src/zope/app/event/tests/test_objectevent.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/event/tests/test_objectevent.py:1.3 Mon Dec 30 09:03:05 2002
+++ Zope3/src/zope/app/event/tests/test_objectevent.py Sun Sep 21 13:32:09 2003
@@ -19,74 +19,33 @@
import unittest
-from zope.app.event.objectevent import ObjectAddedEvent
from zope.app.event.objectevent import ObjectModifiedEvent
-from zope.app.event.objectevent import ObjectRemovedEvent
-from zope.app.event.objectevent import ObjectMovedEvent
from zope.app.event.objectevent import ObjectAnnotationsModifiedEvent
from zope.app.event.objectevent import ObjectContentModifiedEvent
-class TestObjectAddedEvent(unittest.TestCase):
+class TestObjectModifiedEvent(unittest.TestCase):
+
+ klass = ObjectModifiedEvent
- location = '/some/location'
object = object()
- klass = ObjectAddedEvent
def setUp(self):
- self.event = self.klass(self.object, self.location)
-
- def testGetLocation(self):
- self.assertEqual(self.event.location, self.location)
+ self.event = self.klass(self.object)
def testGetObject(self):
self.assertEqual(self.event.object, self.object)
-class TestObjectModifiedEvent(TestObjectAddedEvent):
-
- klass = ObjectModifiedEvent
-
-class TestObjectAnnotationsModifiedEvent(TestObjectAddedEvent):
+class TestObjectAnnotationsModifiedEvent(TestObjectModifiedEvent):
klass = ObjectAnnotationsModifiedEvent
-class TestObjectContentModifiedEvent(TestObjectAddedEvent):
+class TestObjectContentModifiedEvent(TestObjectModifiedEvent):
klass = ObjectContentModifiedEvent
-
-class TestObjectRemovedEvent(TestObjectAddedEvent):
-
-
- location = '/some/location'
-
- def setUp(self):
- self.event = ObjectRemovedEvent(self.object, self.location)
-
- def testGetLocation(self):
- self.assertEqual(self.event.location, self.location)
-
- def testGetObject(self):
- self.assertEqual(self.event.object, self.object)
-
-
-
-class TestObjectMovedEvent(TestObjectAddedEvent):
-
- from_location = '/some/other/location'
-
- def setUp(self):
- self.event = ObjectMovedEvent(self.object,
- self.from_location, self.location)
-
- def testFromLocation(self):
- self.assertEqual(self.event.fromLocation, self.from_location)
-
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(TestObjectAddedEvent),
unittest.makeSuite(TestObjectModifiedEvent),
unittest.makeSuite(TestObjectAnnotationsModifiedEvent),
unittest.makeSuite(TestObjectContentModifiedEvent),
- unittest.makeSuite(TestObjectRemovedEvent),
- unittest.makeSuite(TestObjectMovedEvent)
))
if __name__=='__main__':
More information about the Zope3-Checkins
mailing list