[Zope3-checkins] CVS: Zope3/src/zope/app/observable - tests.py:1.3

Nathan Yergler nathan at yergler.net
Tue Mar 30 16:47:51 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/observable
In directory cvs.zope.org:/tmp/cvs-serv8257/src/zope/app/observable

Modified Files:
	tests.py 
Log Message:


Moved tests for ObserverEvent event channel into zope.app.observable.


=== Zope3/src/zope/app/observable/tests.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/observable/tests.py:1.2	Tue Mar 30 09:13:57 2004
+++ Zope3/src/zope/app/observable/tests.py	Tue Mar 30 16:47:50 2004
@@ -11,7 +11,7 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Tests for the Observable Adapter.
+"""Tests for the Observable event infrastructure.
 
 $Id$
 """
@@ -25,6 +25,8 @@
 from zope.app.event.interfaces import ISubscriber
 from zope.app.annotation.interfaces import IAnnotations
 from zope.app.container.interfaces import IObjectAddedEvent
+from zope.app.container.interfaces import IObjectRemovedEvent
+from zope.app.observable import observerevent
 
 class DummyAnnotationsClass(dict):
     implements(IAnnotations)
@@ -100,6 +102,60 @@
     >>> adapter.notify(event, ISubscriber)
     >>> subscriber.events == [event]
     True
+    """
+
+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()
+
+def testObservableEvents(self):
+    """
+    When an object that has subscriptions change, the
+    subscribers are notified.
+
+    >>> event = DummyObservableEvent()
+    >>> notifier = observerevent.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 = observerevent.ObserverEventNotifier()
+    >>> notifier.notify(event)
+    >>> event.object.flag
+    False
     """
 
 def test_suite():




More information about the Zope3-Checkins mailing list