[Zope3-checkins] CVS: Zope3/src/zope/app/browser/container/tests -
test_adding.py:1.10.6.1 test_contents.py:1.24.6.1
Jim Fulton
jim at zope.com
Mon Sep 8 15:22:25 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/container/tests
In directory cvs.zope.org:/tmp/cvs-serv20092/src/zope/app/browser/container/tests
Modified Files:
Tag: parentgeddon-branch
test_adding.py test_contents.py
Log Message:
Checking in work in progress on parentgeddon-branch so Fred can help
me to get the tests passing. Specific log entries will be provided
when we merge this into the head.
=== Zope3/src/zope/app/browser/container/tests/test_adding.py 1.10 => 1.10.6.1 ===
--- Zope3/src/zope/app/browser/container/tests/test_adding.py:1.10 Sun Aug 17 02:05:39 2003
+++ Zope3/src/zope/app/browser/container/tests/test_adding.py Mon Sep 8 14:21:24 2003
@@ -20,9 +20,8 @@
from zope.app import zapi
from zope.app.browser.absoluteurl import AbsoluteURL
from zope.app.browser.container.adding import Adding
-from zope.app.context import ContextWrapper
from zope.app.event.tests.placelesssetup import getEvents
-from zope.app.interfaces.container import IAdding, IZopeContainer
+from zope.app.interfaces.container import IAdding, IAddTarget
from zope.app.interfaces.event import IObjectAddedEvent, IObjectModifiedEvent
from zope.app.interfaces.exceptions import UserError
from zope.app.interfaces.traversing import IContainmentRoot
@@ -31,24 +30,22 @@
from zope.component.factory import provideFactory
from zope.component.interfaces import IFactory
from zope.component.exceptions import ComponentLookupError
-from zope.context import getWrapperContainer, getWrapperData
-from zope.context import \
- getWrapperContainer, getWrapperData, getInnerWrapperData
from zope.interface import implements, Interface
from zope.publisher.browser import TestRequest, BrowserView
from zope.publisher.interfaces.browser import IBrowserPresentation
+from zope.app.container.contained import contained
class Root:
implements(IContainmentRoot)
class Container(dict):
- implements(IZopeContainer)
+ implements(IAddTarget)
- def setObject(self, name, obj):
+ def addObject(self, name, obj):
if name is None:
name = 'chosen'
- self[name] = obj
+ self[name] = contained(obj, self, name)
return name
@@ -74,7 +71,7 @@
def __str__(self):
if IContainmentRoot.isImplementedBy(self.context):
return ''
- name = getInnerWrapperData(self.context)['name']
+ name = self.context.__name__
url = str(zapi.getView(
zapi.getParent(self.context), 'absolute_url', self.request))
url += '/' + name
@@ -88,8 +85,6 @@
def test(self):
container = Container()
- # ensure container provides IZopeContainer
- container = ContextWrapper(container, None)
request = TestRequest()
adding = Adding(container, request)
provideView(IAdding, "Thing", IBrowserPresentation, CreationView)
@@ -105,25 +100,11 @@
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(result.__parent__, container)
self.assertEqual(result, o)
- self.assertEqual(getWrapperData(result)["name"], "foo")
+ self.assertEqual(result.__name__, "foo")
def testNoNameGiven(self):
container = Container()
@@ -173,11 +154,10 @@
def test_action(self):
container = Container()
- # ensure container provides IZopeContainer
- container = ContextWrapper(container, Root(), name="container")
+ container = contained(container, Root(), "container")
request = TestRequest()
adding = Adding(container, request)
- adding = ContextWrapper(adding, container, name="+")
+ adding.__name__ = '+'
provideView(IAdding, "Thing", IBrowserPresentation, CreationView)
provideView(Interface, "absolute_url", IBrowserPresentation,
AbsoluteURL)
=== Zope3/src/zope/app/browser/container/tests/test_contents.py 1.24 => 1.24.6.1 ===
--- Zope3/src/zope/app/browser/container/tests/test_contents.py:1.24 Sun Aug 17 02:05:39 2003
+++ Zope3/src/zope/app/browser/container/tests/test_contents.py Mon Sep 8 14:21:24 2003
@@ -52,6 +52,7 @@
from zope.app.interfaces.services.principalannotation \
import IPrincipalAnnotationService
from zope.app.interfaces.annotation import IAnnotations
+from zope.app.container.contained import contained
class BaseTestContentsBrowserView(PlacelessSetup):
"""Base class for testing browser contents.
@@ -132,32 +133,10 @@
fc = self._TestView__newView(container)
- self.failIf(getEvents(IObjectRemovedEvent))
- self.failUnless(
- getEvents(IObjectModifiedEvent,
- filter =
- lambda event:
- removeAllProxies(event.object) == container)
- )
- clearEvents()
-
fc.request.form.update({'ids': ['document2']})
fc.removeObjects()
- self.failUnless(
- getEvents(IObjectRemovedEvent,
- filter =
- lambda event:
- removeAllProxies(event.object) == document2)
- )
- self.failUnless(
- getEvents(IObjectModifiedEvent,
- filter =
- lambda event:
- removeAllProxies(event.object) == container)
- )
-
info_list = fc.listContentInfo()
self.assertEquals(len(info_list), 2)
@@ -320,10 +299,9 @@
def _TestView__newContext(self):
from zope.app.container.sample import SampleContainer
from zope.app.content.folder import RootFolder
- from zope.app.context import ContextWrapper
root = RootFolder()
container = SampleContainer()
- return ContextWrapper(container, root, name='sample')
+ return contained(container, root, 'sample')
def _TestView__newView(self, container):
from zope.app.browser.container.contents import Contents
More information about the Zope3-Checkins
mailing list