[Zope3-checkins] CVS: Zope3/src/zope/app/browser/container/tests - test_adding.py:1.10.6.2 test_contents.py:1.24.6.2

Jim Fulton jim at zope.com
Fri Sep 12 15:16:10 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/browser/container/tests
In directory cvs.zope.org:/tmp/cvs-serv13470/src/zope/app/browser/container/tests

Modified Files:
      Tag: parentgeddon-branch
	test_adding.py test_contents.py 
Log Message:
Can't have the tests passing, can we?

=== Zope3/src/zope/app/browser/container/tests/test_adding.py 1.10.6.1 => 1.10.6.2 ===
--- Zope3/src/zope/app/browser/container/tests/test_adding.py:1.10.6.1	Mon Sep  8 14:21:24 2003
+++ Zope3/src/zope/app/browser/container/tests/test_adding.py	Fri Sep 12 15:15:08 2003
@@ -21,8 +21,9 @@
 from zope.app.browser.absoluteurl import AbsoluteURL
 from zope.app.browser.container.adding import Adding
 from zope.app.event.tests.placelesssetup import getEvents
-from zope.app.interfaces.container import IAdding, IAddTarget
-from zope.app.interfaces.event import IObjectAddedEvent, IObjectModifiedEvent
+from zope.app.interfaces.container import IAdding
+from zope.app.interfaces.container import IObjectAddedEvent
+from zope.app.interfaces.event import IObjectModifiedEvent
 from zope.app.interfaces.exceptions import UserError
 from zope.app.interfaces.traversing import IContainmentRoot
 from zope.app.tests.placelesssetup import PlacelessSetup
@@ -34,19 +35,16 @@
 from zope.publisher.browser import TestRequest, BrowserView
 from zope.publisher.interfaces.browser import IBrowserPresentation
 from zope.app.container.contained import contained
+import zope.security.checker
+from zope.exceptions import ForbiddenAttribute
+from zope.app.interfaces.container import IWriteContainer
 
 class Root:
     implements(IContainmentRoot)
 
 class Container(dict):
 
-    implements(IAddTarget)
-
-    def addObject(self, name, obj):
-        if name is None:
-            name = 'chosen'
-        self[name] = contained(obj, self, name)
-        return name
+    implements(IWriteContainer)
 
 
 class CreationView(BrowserView):
@@ -117,11 +115,22 @@
         self.assertEqual(adding.contentName, '')
 
     def testAction(self):
-        provideFactory('foo', Factory())
+        # make a private factory
+        provideFactory('fooprivate', Factory())
+
+        factory = Factory()
+        factory.__Security_checker__ = zope.security.checker.NamesChecker(
+            ['__call__'])
+        provideFactory('foo', factory)
+
         container = Container()
         adding = Adding(container, TestRequest())
         adding.nextURL = lambda: '.'
         adding.namesAccepted = lambda: True
+
+        # we can't use a private factory:
+        self.assertRaises(ForbiddenAttribute, 
+                          adding.action, type_name='fooprivate', id='bar')
 
         # typical add - id is provided by user
         adding.action(type_name='foo', id='bar')


=== Zope3/src/zope/app/browser/container/tests/test_contents.py 1.24.6.1 => 1.24.6.2 ===
--- Zope3/src/zope/app/browser/container/tests/test_contents.py:1.24.6.1	Mon Sep  8 14:21:24 2003
+++ Zope3/src/zope/app/browser/container/tests/test_contents.py	Fri Sep 12 15:15:08 2003
@@ -28,20 +28,13 @@
 from zope.app.traversing import traverse
 from zope.app.interfaces.copypastemove import IObjectMover
 from zope.app.interfaces.copypastemove import IObjectCopier
-from zope.app.interfaces.container import IPasteTarget
-from zope.app.interfaces.container import IMoveSource
-from zope.app.interfaces.container import ICopySource
-from zope.app.interfaces.container import IPasteNamesChooser
 
 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.event.tests.placelesssetup import getEvents, clearEvents
-from zope.app.interfaces.event import IObjectRemovedEvent, IObjectModifiedEvent
+from zope.app.interfaces.event import IObjectModifiedEvent
+from zope.app.interfaces.container import IObjectRemovedEvent
 from zope.interface import Interface, implements
 from zope.proxy import removeAllProxies
 
@@ -72,9 +65,9 @@
         # Do we get the correct information back from ContainerContents?
         container = self._TestView__newContext()
         subcontainer = self._TestView__newContext()
-        container.setObject('subcontainer', subcontainer)
+        container['subcontainer'] = subcontainer
         document = Document()
-        container.setObject('document', document)
+        container['document'] = document
 
         fc = self._TestView__newView(container)
         info_list = fc.listContentInfo()
@@ -95,7 +88,7 @@
     def testInfoWDublinCore(self):
         container = self._TestView__newContext()
         document = Document()
-        container.setObject('document', document)
+        container['document'] = document
 
         from datetime import datetime
         from zope.app.interfaces.dublincore import IZopeDublinCore
@@ -125,11 +118,11 @@
     def testRemove(self):
         container = self._TestView__newContext()
         subcontainer = self._TestView__newContext()
-        container.setObject('subcontainer', subcontainer)
+        container['subcontainer'] = subcontainer
         document = Document()
-        container.setObject('document', document)
+        container['document'] = document
         document2 = Document()
-        container.setObject('document2', document2)
+        container['document2'] = document2
 
         fc = self._TestView__newView(container)
 
@@ -170,10 +163,6 @@
         PlacefulSetup.buildFolders(self)
         provideAdapter(None, IObjectCopier, ObjectCopier)
         provideAdapter(None, IObjectMover, ObjectMover)
-        provideAdapter(IContainer, IPasteTarget, PasteTarget)
-        provideAdapter(IContainer, IMoveSource, MoveSource)
-        provideAdapter(IContainer, ICopySource, CopySource)
-        provideAdapter(IContainer, IPasteNamesChooser, PasteNamesChooser)
 
         provideAdapter(IAnnotations, IPrincipalClipboard, PrincipalClipboard)
         root_sm = getServiceManager(None)
@@ -188,7 +177,7 @@
         ids=['document1', 'document2']
         for id in ids:
             document = Document()
-            container.setObject(id, document)
+            container[id] = document
         fc.request.form.update({'rename_ids': ids,
                                 'new_value': ['document1_1', 'document2_2']
                                 })
@@ -202,7 +191,7 @@
         ids=['document1', 'document2']
         for id in ids:
             document = Document()
-            container.setObject(id, document)
+            container[id] = document
 
         fc.request.form['ids'] = ids
         fc.copyObjects()
@@ -250,7 +239,7 @@
         ids=['document1', 'document2']
         for id in ids:
             document = Document()
-            container.setObject(id, document)
+            container[id] = document
         fc.request.form['ids'] = ids
         fc.cutObjects()
         fc.pasteObjects()




More information about the Zope3-Checkins mailing list