[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/tests - testAdding.py:1.3
Jeremy Hylton
jeremy@zope.com
Wed, 2 Oct 2002 17:35:47 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv25863/lib/python/Zope/App/OFS/Container/Views/Browser/tests
Modified Files:
testAdding.py
Log Message:
Extend defintion of add() of IAdding interface.
add() should return the added object in the context of the container.
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/tests/testAdding.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/tests/testAdding.py:1.2 Wed Jul 17 12:54:17 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/tests/testAdding.py Wed Oct 2 17:35:47 2002
@@ -20,16 +20,24 @@
from Zope.App.OFS.Container.Views.Browser.Adding import Adding
from Zope.App.OFS.Container.IAdding import IAdding
-from Zope.Publisher.Browser.BrowserRequest import TestRequest
from Zope.ComponentArchitecture.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.ComponentArchitecture.GlobalViewService import provideView
class Container:
- data = ()
- def setObject(self, *args):
- self.data += args
+ def __init__(self):
+ self._data = {}
+
+ def setObject(self, name, obj):
+ self._data[name] = obj
+ return name
+
+ def __getitem__(self, name):
+ return self._data[name]
class CreationView(BrowserView):
@@ -48,8 +56,12 @@
view = adding.publishTraverse(request, 'Thing=foo')
self.assertEqual(view.action(), 'been there, done that')
self.assertEqual(adding.contentName, 'foo')
- adding.add(42)
- self.assertEqual(container.data, ('foo', 42))
+ o = Container() # any old instance will do
+ result = adding.add(o)
+ self.assertEqual(container["foo"], o)
+ self.assertEqual(getWrapperContainer(result), container)
+ self.assertEqual(getWrapperObject(result), o)
+ self.assertEqual(getWrapperData(result)["name"], "foo")
def test_suite():
return makeSuite(Test)