[Zope3-checkins] CVS: Zope3/src/zope/app/browser/container/tests - test_adding.py:1.2.28.1 test_contents.py:1.13.12.1
Grégoire Weber
zope@i-con.ch
Sun, 22 Jun 2003 10:24:08 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/container/tests
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/app/browser/container/tests
Modified Files:
Tag: cw-mail-branch
test_adding.py test_contents.py
Log Message:
Synced up with HEAD
=== Zope3/src/zope/app/browser/container/tests/test_adding.py 1.2 => 1.2.28.1 ===
--- Zope3/src/zope/app/browser/container/tests/test_adding.py:1.2 Wed Dec 25 09:12:30 2002
+++ Zope3/src/zope/app/browser/container/tests/test_adding.py Sun Jun 22 10:22:37 2003
@@ -22,23 +22,20 @@
from zope.app.interfaces.container import IAdding
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.component.view import provideView
-from zope.proxy.context \
- import getWrapperObject, getWrapperContainer, getWrapperData
+from zope.context import getWrapperContainer, getWrapperData
from zope.publisher.browser import TestRequest
from zope.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.app.event.tests.placelesssetup import getEvents
from zope.app.interfaces.event import IObjectAddedEvent, IObjectModifiedEvent
-from zope.app.interfaces.container import IZopeContainer
from zope.app.interfaces.container import IContainer
-from zope.app.container.zopecontainer import ZopeContainerAdapter
-
-
+from zope.interface import implements
+from zope.app.context import ContextWrapper
class Container:
- __implements__ = IContainer
+ implements(IContainer)
def __init__(self):
self._data = {}
@@ -59,10 +56,11 @@
def setUp(self):
PlacelessSetup.setUp(self)
- provideAdapter(IContainer, IZopeContainer, ZopeContainerAdapter)
def test(self):
container = Container()
+ # ensure container provides IZopeContainer
+ container = ContextWrapper(container, None)
request = TestRequest()
adding = Adding(container, request)
provideView(IAdding, "Thing", IBrowserPresentation, CreationView)
@@ -95,7 +93,7 @@
# Check the state of the container and result
self.assertEqual(container["foo"], o)
self.assertEqual(getWrapperContainer(result), container)
- self.assertEqual(getWrapperObject(result), o)
+ self.assertEqual(result, o)
self.assertEqual(getWrapperData(result)["name"], "foo")
def testNoNameGiven(self):
=== Zope3/src/zope/app/browser/container/tests/test_contents.py 1.13 => 1.13.12.1 ===
--- Zope3/src/zope/app/browser/container/tests/test_contents.py:1.13 Wed Apr 30 19:37:50 2003
+++ Zope3/src/zope/app/browser/container/tests/test_contents.py Sun Jun 22 10:22:37 2003
@@ -26,10 +26,8 @@
from zope.app.interfaces.container import IZopeContainer
from zope.app.interfaces.container import IContainer
from zope.app.interfaces.copypastemove import IObjectMover
-from zope.app.container.zopecontainer import ZopeContainerAdapter
from zope.app.traversing import traverse
-from zope.app.traversing import IObjectName
from zope.app.interfaces.copypastemove import IObjectMover
from zope.app.interfaces.copypastemove import IObjectCopier
from zope.app.interfaces.container import IPasteTarget
@@ -37,25 +35,22 @@
from zope.app.interfaces.container import ICopySource
from zope.app.interfaces.container import IPasteNamesChooser
-from zope.app.traversing.adapters import ObjectName
from zope.app.copypastemove import ObjectMover
from zope.app.copypastemove import ObjectCopier
from zope.app.container.copypastemove import PasteTarget
from zope.app.container.copypastemove import MoveSource
from zope.app.container.copypastemove import CopySource
from zope.app.container.copypastemove import PasteNamesChooser
-from zope.app.container.zopecontainer import ZopeContainerAdapter
-from zope.app.event.tests.placelesssetup import getEvents
+from zope.app.event.tests.placelesssetup import getEvents, clearEvents
from zope.app.interfaces.event import IObjectRemovedEvent, IObjectModifiedEvent
-from zope.interface import Interface
-from zope.proxy.introspection import removeAllProxies
+from zope.interface import Interface, implements
+from zope.proxy import removeAllProxies
from zope.app.interfaces.copypastemove import IPrincipalClipboard
from zope.app.copypastemove import PrincipalClipboard
from zope.component import getServiceManager
-from zope.app.services.principalannotation \
- import PrincipalAnnotationService
+from zope.app.services.principalannotation import PrincipalAnnotationService
from zope.app.interfaces.services.principalannotation \
import IPrincipalAnnotationService
from zope.app.interfaces.annotation import IAnnotations
@@ -72,8 +67,6 @@
def setUp(self):
PlacelessSetup.setUp(self)
- provideAdapter(IContainer, IZopeContainer, ZopeContainerAdapter)
- provideAdapter(ITraversable, IZopeContainer, ZopeContainerAdapter)
provideAdapter(None, IObjectMover, ObjectMover)
def testInfo(self):
@@ -108,7 +101,7 @@
from datetime import datetime
from zope.app.interfaces.dublincore import IZopeDublinCore
class FauxDCAdapter:
- __implements__ = IZopeDublinCore
+ implements(IZopeDublinCore)
def __init__(self, context):
pass
@@ -127,8 +120,8 @@
self.assertEqual(info['url'], 'document')
self.assertEqual(info['object'], document)
self.assertEqual(info['title'], 'faux title')
- self.assertEqual(info['created'], 'Jan 1, 2001')
- self.assertEqual(info['modified'], 'Feb 2, 2002')
+ self.assertEqual(info['created'], '1/1/01 2:01 AM ')
+ self.assertEqual(info['modified'], '2/2/02 3:02 AM ')
def testRemove(self):
container = self._TestView__newContext()
@@ -141,10 +134,18 @@
fc = self._TestView__newView(container)
- self.failIf(getEvents(IObjectModifiedEvent))
self.failIf(getEvents(IObjectRemovedEvent))
+ self.failUnless(
+ getEvents(IObjectModifiedEvent,
+ filter =
+ lambda event:
+ removeAllProxies(event.object) == container)
+ )
+ clearEvents()
- fc.removeObjects(['document2'])
+ fc.request.form.update({'ids': ['document2']})
+
+ fc.removeObjects()
self.failUnless(
getEvents(IObjectRemovedEvent,
@@ -176,22 +177,25 @@
pass
class Document:
- __implements__ = IDocument
+ implements(IDocument)
+
+
+class Principal:
+
+ def getId(self):
+ return 'bob'
class TestCutCopyPaste(PlacefulSetup, TestCase):
-
+
def setUp(self):
PlacefulSetup.setUp(self)
PlacefulSetup.buildFolders(self)
- provideAdapter(IContainer, IZopeContainer, ZopeContainerAdapter)
- provideAdapter(ITraversable, IZopeContainer, ZopeContainerAdapter)
provideAdapter(None, IObjectCopier, ObjectCopier)
provideAdapter(None, IObjectMover, ObjectMover)
provideAdapter(IContainer, IPasteTarget, PasteTarget)
provideAdapter(IContainer, IMoveSource, MoveSource)
provideAdapter(IContainer, ICopySource, CopySource)
- provideAdapter(None, IObjectName, ObjectName)
provideAdapter(IContainer, IPasteNamesChooser, PasteNamesChooser)
provideAdapter(IAnnotations, IPrincipalClipboard, PrincipalClipboard)
@@ -208,7 +212,10 @@
for id in ids:
document = Document()
container.setObject(id, document)
- fc.renameObjects(ids, ['document1_1', 'document2_2'])
+ fc.request.form.update({'rename_ids': ids,
+ 'new_value': ['document1_1', 'document2_2']
+ })
+ fc.renameObjects()
self.failIf('document1_1' not in container)
self.failIf('document1' in container)
@@ -219,7 +226,9 @@
for id in ids:
document = Document()
container.setObject(id, document)
- fc.copyObjects(ids)
+
+ fc.request.form['ids'] = ids
+ fc.copyObjects()
fc.pasteObjects()
self.failIf('document1' not in container)
self.failIf('document2' not in container)
@@ -230,7 +239,8 @@
container = traverse(self.rootFolder, 'folder1')
fc = self._TestView__newView(container)
ids = ['folder1_1']
- fc.copyObjects(ids)
+ fc.request.form['ids'] = ids
+ fc.copyObjects()
fc.pasteObjects()
self.failIf('folder1_1' not in container)
self.failIf('copy_of_folder1_1' not in container)
@@ -239,7 +249,8 @@
container = traverse(self.rootFolder, '/folder1/folder1_1')
fc = self._TestView__newView(container)
ids = ['folder1_1_1']
- fc.copyObjects(ids)
+ fc.request.form['ids'] = ids
+ fc.copyObjects()
fc.pasteObjects()
self.failIf('folder1_1_1' not in container)
self.failIf('copy_of_folder1_1_1' not in container)
@@ -250,7 +261,8 @@
fc = self._TestView__newView(container)
tg = self._TestView__newView(target)
ids = ['folder1_1_1']
- fc.copyObjects(ids)
+ fc.request.form['ids'] = ids
+ fc.copyObjects()
tg.pasteObjects()
self.failIf('folder1_1_1' not in container)
self.failIf('folder1_1_1' not in target)
@@ -262,7 +274,8 @@
for id in ids:
document = Document()
container.setObject(id, document)
- fc.cutObjects(ids)
+ fc.request.form['ids'] = ids
+ fc.cutObjects()
fc.pasteObjects()
self.failIf('document1' not in container)
self.failIf('document2' not in container)
@@ -271,7 +284,8 @@
container = traverse(self.rootFolder, 'folder1')
fc = self._TestView__newView(container)
ids = ['folder1_1']
- fc.cutObjects(ids)
+ fc.request.form['ids'] = ids
+ fc.cutObjects()
fc.pasteObjects()
self.failIf('folder1_1' not in container)
@@ -279,7 +293,8 @@
container = traverse(self.rootFolder, '/folder1/folder1_1')
fc = self._TestView__newView(container)
ids = ['folder1_1_1']
- fc.cutObjects(ids)
+ fc.request.form['ids'] = ids
+ fc.cutObjects()
fc.pasteObjects()
self.failIf('folder1_1_1' not in container)
@@ -289,7 +304,8 @@
fc = self._TestView__newView(container)
tg = self._TestView__newView(target)
ids = ['folder1_1_1']
- fc.cutObjects(ids)
+ fc.request.form['ids'] = ids
+ fc.cutObjects()
tg.pasteObjects()
self.failIf('folder1_1_1' in container)
self.failIf('folder1_1_1' not in target)
@@ -297,14 +313,16 @@
def _TestView__newView(self, container):
from zope.app.browser.container.contents import Contents
from zope.publisher.browser import TestRequest
- return Contents(container, TestRequest())
+ request = TestRequest()
+ request.setUser(Principal())
+ return Contents(container, request)
class Test(BaseTestContentsBrowserView, TestCase):
def _TestView__newContext(self):
from zope.app.container.sample import SampleContainer
from zope.app.content.folder import RootFolder
- from zope.proxy.context import ContextWrapper
+ from zope.app.context import ContextWrapper
root = RootFolder()
container = SampleContainer()
return ContextWrapper(container, root, name='sample')