[Zope3-checkins] CVS: Zope3/src/zope/app/event/tests - test_objectevent.py:1.10

Nathan Yergler nathan at yergler.net
Tue Mar 30 09:13:25 EST 2004


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

Modified Files:
	test_objectevent.py 
Log Message:


Merging observable-branch 
(added subscriber ZCML directive.)




=== Zope3/src/zope/app/event/tests/test_objectevent.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/event/tests/test_objectevent.py:1.9	Mon Mar 15 15:41:43 2004
+++ Zope3/src/zope/app/event/tests/test_objectevent.py	Tue Mar 30 09:13:24 2004
@@ -18,7 +18,9 @@
 """
 
 import unittest
+import doctest
 
+from zope.interface import implements
 from zope.app.event.objectevent import ObjectModifiedEvent
 from zope.app.event.objectevent import ObjectAnnotationsModifiedEvent
 from zope.app.event.objectevent import ObjectContentModifiedEvent
@@ -31,7 +33,7 @@
 from zope.app.tests.placelesssetup import setUp, tearDown
 from zope.app.servicenames import Adapters, EventPublication
 from zope.component import getService
-
+from zope.app.observable.interfaces import IObservable
 
 class TestObjectModifiedEvent(unittest.TestCase):
 
@@ -51,6 +53,62 @@
 class TestObjectContentModifiedEvent(TestObjectModifiedEvent):
     klass = ObjectContentModifiedEvent
 
+class DummyObservable:
+    implements(IObservable)
+
+    def __init__(self):
+        self.flag = False
+
+    def notify(self, event, provided):
+        self.flag = True
+
+class DummyNotObservable:
+    
+    def __init__(self):
+        self.flag = False
+        
+    def notify(self, event, provided):
+        self.flag = True
+
+class DummyObservableEvent:
+    implements(IObjectRemovedEvent, IObservable)
+
+    def __init__(self):
+        self.object = DummyObservable()
+
+class DummyNotObservableEvent:
+    implements(IObjectRemovedEvent)
+    
+    def __init__(self):
+        self.object = DummyNotObservable()
+
+class TestObserverEventNotifications:
+
+    def testObservableEvents(self):
+        """
+        When an object that has subscriptions change, the
+        subscribers are notified.
+        
+        >>> event = DummyObservableEvent()
+        >>> notifier = objectevent.ObserverEventNotifier()
+        >>> notifier.notify(event)
+        >>> event.object.flag
+        True
+        """
+
+    def testNotObservableEvents(self):
+        """
+        
+        When an object that has no subscriptions changes, the
+        ObserverEventNotifier doesn't do anything to it.
+
+        >>> event = DummyNotObservableEvent()
+        >>> notifier = objectevent.ObserverEventNotifier()
+        >>> notifier.notify(event)
+        >>> event.object.flag
+        False
+        """
+
 class TestObjectEventNotifications(unittest.TestCase):
     def setUp(self):
         self.callbackTriggered = False
@@ -115,6 +173,7 @@
         unittest.makeSuite(TestObjectAnnotationsModifiedEvent),
         unittest.makeSuite(TestObjectContentModifiedEvent),
         unittest.makeSuite(TestObjectEventNotifications),
+        doctest.DocTestSuite(),
         ))
 
 if __name__=='__main__':




More information about the Zope3-Checkins mailing list