[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/tests - testAdding.py:1.4
Jim Fulton
jim@zope.com
Fri, 4 Oct 2002 15:48:31 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv4279/lib/python/Zope/App/OFS/Container/Views/Browser/tests
Modified Files:
testAdding.py
Log Message:
Added logic to generate object events when objects are modified,
created, or added.
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/tests/testAdding.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/tests/testAdding.py:1.3 Wed Oct 2 17:35:47 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/tests/testAdding.py Fri Oct 4 15:48:31 2002
@@ -20,13 +20,15 @@
from Zope.App.OFS.Container.Views.Browser.Adding import Adding
from Zope.App.OFS.Container.IAdding import IAdding
-from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
+from Zope.App.tests.PlacelessSetup import PlacelessSetup
from Zope.ComponentArchitecture.GlobalViewService import provideView
from Zope.Proxy.ContextWrapper \
import getWrapperObject, getWrapperContainer, getWrapperData
from Zope.Publisher.Browser.BrowserRequest import TestRequest
from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.Publisher.Browser.IBrowserPresentation import IBrowserPresentation
+from Zope.Event.tests.PlacelessSetup import getEvents
+from Zope.Event.IObjectEvent import IObjectAddedEvent, IObjectModifiedEvent
class Container:
def __init__(self):
@@ -56,8 +58,29 @@
view = adding.publishTraverse(request, 'Thing=foo')
self.assertEqual(view.action(), 'been there, done that')
self.assertEqual(adding.contentName, 'foo')
+
+ # Make sure we don't have any events yet:
+ self.failIf(getEvents(IObjectModifiedEvent))
+ self.failIf(getEvents(IObjectAddedEvent))
+
o = Container() # any old instance will do
result = adding.add(o)
+
+ # Make sure the right events were generated:
+ self.failUnless(
+ getEvents(IObjectAddedEvent,
+ filter =
+ lambda event:
+ event.object == o)
+ )
+ self.failUnless(
+ getEvents(IObjectModifiedEvent,
+ filter =
+ lambda event:
+ event.object == container)
+ )
+
+ # Check the state of the container and result
self.assertEqual(container["foo"], o)
self.assertEqual(getWrapperContainer(result), container)
self.assertEqual(getWrapperObject(result), o)