[Checkins] SVN: five.grok/trunk/ Added tests for grok.subscriber
directive
Godefroid Chapelle
gotcha at bubblenet.be
Fri May 2 04:52:41 EDT 2008
Log message for revision 86048:
Added tests for grok.subscriber directive
[kamon]
Changed:
U five.grok/trunk/docs/HISTORY.txt
A five.grok/trunk/src/five/grok/tests/subscribers.py
U five.grok/trunk/src/five/grok/tests/test_all.py
-=-
Modified: five.grok/trunk/docs/HISTORY.txt
===================================================================
--- five.grok/trunk/docs/HISTORY.txt 2008-05-02 08:45:16 UTC (rev 86047)
+++ five.grok/trunk/docs/HISTORY.txt 2008-05-02 08:52:40 UTC (rev 86048)
@@ -1,8 +1,14 @@
-Changelog
-=========
+Changelog for five.grok
+-----------------------
-0.1 - Unreleased
-----------------
+ (name of developer listed in brackets)
-* Initial release
+five.grok - 0.1 Unreleased
+ - Added tests for grok.subscriber directive
+ [kamon]
+
+ - Initial release (tests for adapters and utilities, initial support for
+ views)
+ [regebro, gotcha]
+
Added: five.grok/trunk/src/five/grok/tests/subscribers.py
===================================================================
--- five.grok/trunk/src/five/grok/tests/subscribers.py (rev 0)
+++ five.grok/trunk/src/five/grok/tests/subscribers.py 2008-05-02 08:52:40 UTC (rev 86048)
@@ -0,0 +1,38 @@
+"""Testing that grokcore subscribers work under Zope2
+
+You can subscribe to events using the @grok.subscribe decorator:
+
+ >>> from OFS.SimpleItem import SimpleItem
+ >>> item = SimpleItem()
+ >>> item.id = 'one'
+ >>> zope.event.notify(ObjectEvent(item))
+ >>> items
+ ['one']
+ >>> items2
+ ['ONE']
+
+The decorated event handling function can also be called directly:
+
+ >>> otheritem = SimpleItem()
+ >>> otheritem.id = 'two'
+ >>> itemAdded(otheritem,None)
+ >>> items
+ ['one', 'two']
+
+"""
+import zope.event
+import grokcore.component as grok
+from zope.component.interfaces import IObjectEvent, ObjectEvent
+
+from OFS.interfaces import ISimpleItem
+
+items = []
+items2 = []
+
+ at grok.subscribe(ISimpleItem, IObjectEvent)
+def itemAdded(item, event):
+ items.append(item.getId())
+
+ at grok.subscribe(ISimpleItem, IObjectEvent)
+def itemAddedInstance(item, event):
+ items2.append(item.getId().upper())
\ No newline at end of file
Modified: five.grok/trunk/src/five/grok/tests/test_all.py
===================================================================
--- five.grok/trunk/src/five/grok/tests/test_all.py 2008-05-02 08:45:16 UTC (rev 86047)
+++ five.grok/trunk/src/five/grok/tests/test_all.py 2008-05-02 08:52:40 UTC (rev 86048)
@@ -35,9 +35,13 @@
setUp=setUp, tearDown=testing.tearDown),
doctestunit.DocTestSuite(
+ module='five.grok.tests.subscribers',
+ setUp=setUp, tearDown=testing.tearDown),
+
+ doctestunit.DocTestSuite(
module='five.grok.tests.views',
setUp=setUp, tearDown=testing.tearDown),
-
+
# Integration tests that use ZopeTestCase
#ztc.ZopeDocFileSuite(
# 'README.txt', package='something.foo',
More information about the Checkins
mailing list