[Zope3-checkins] CVS: Zope3/src/zope/app/container/tests - placelesssetup.py:1.2.2.1 test_zopecontainer.py:1.3.2.1 baseizopeitemcontainer.py:1.3.18.1 test_containertraversable.py:1.4.10.1 test_containertraverser.py:1.7.10.1 test_find.py:1.3.10.1 test_objectcopier.py:1.7.10.1 test_objectmover.py:1.5.10.1 test_rename.py:1.4.10.1 test_size.py:1.1.26.1 test_zopecontaineradpter.py:NONE

Grégoire Weber zope@i-con.ch
Sun, 22 Jun 2003 10:23:57 -0400


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

Modified Files:
      Tag: cw-mail-branch
	baseizopeitemcontainer.py test_containertraversable.py 
	test_containertraverser.py test_find.py test_objectcopier.py 
	test_objectmover.py test_rename.py test_size.py 
Added Files:
      Tag: cw-mail-branch
	placelesssetup.py test_zopecontainer.py 
Removed Files:
      Tag: cw-mail-branch
	test_zopecontaineradpter.py 
Log Message:
Synced up with HEAD

=== Added File Zope3/src/zope/app/container/tests/placelesssetup.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Unit test logic for setting up and tearing down basic infrastructure

$Id: placelesssetup.py,v 1.2.2.1 2003/06/22 14:22:56 gregweb Exp $
"""
from zope.component.adapter import provideAdapter
from zope.app.container.zopecontainer import ZopeContainerDecorator
from zope.app.interfaces.context import IZopeContextWrapper
from zope.app.interfaces.container import IContainer

class PlacelessSetup:

    def setUp(self):
        provideAdapter(
            IContainer, IZopeContextWrapper, ZopeContainerDecorator)


=== Added File Zope3/src/zope/app/container/tests/test_zopecontainer.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""XXX short summary goes here.

XXX longer description goes here.

$Id: test_zopecontainer.py,v 1.3.2.1 2003/06/22 14:22:56 gregweb Exp $
"""

from unittest import TestCase, TestSuite, main, makeSuite
from zope.app.interfaces.container import IAddNotifiable
from zope.app.interfaces.container import IDeleteNotifiable
from zope.app.container.tests.baseizopeitemcontainer import \
     BaseTestIZopeSimpleReadContainer, BaseTestIZopeReadContainer,\
     BaseTestIZopeWriteContainer
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.interface import implements

class C:
    pass

class H:
    implements(IAddNotifiable, IDeleteNotifiable)
    notified = 0
    def beforeDeleteHook(self, object, container):
        self.notified -= 1
    def afterAddHook(self, object, container):
        self.notified += 1

class ItemContainer:
    "Container that implements only __getitem__ for reading."

    def __init__(self):
        self._d = {}

    def __getitem__(self, key):
        return self._d[key]

    def __setitem__(self, key, value):
        self._d[key] = value

class TestZopeItemContainerDecorator(PlacelessSetup,
                                     BaseTestIZopeSimpleReadContainer,
                                     TestCase):
    # Note that this test derives from BaseTestIZopeSimpleReadContainer.
    # This is because the ZopeItemContainerDecorator decorates IItemContainer,
    # and as well as providing context-awareness, it upgrades IItemContainer
    # to ISimpleReadContainer.

    def setUp(self):
        PlacelessSetup.setUp(self)
        self._container = ItemContainer()

    def decorate(self, container):
        from zope.app.container.zopecontainer import ZopeItemContainerDecorator
        return ZopeItemContainerDecorator(container)

    def _sampleMapping(self):
        container = self._container
        for k, v in self._sampleDict().items():
            container[k] = v
        return self.decorate(container)

    def _sampleContainer(self):
        return self._container

    _sample = {'Z': C(), 'O': C(),'P': C()}
    def _sampleDict(self):
        return self._sample

    def _absentKeys(self):
        return 'zc', 'ny'

class TestZopeSimpleReadContainerDecorator(TestZopeItemContainerDecorator,
                                           BaseTestIZopeSimpleReadContainer):

    def setUp(self):
        PlacelessSetup.setUp(self)
        self._container = {}

    def decorate(self, container):
        from zope.app.container.zopecontainer import \
            ZopeSimpleReadContainerDecorator
        return ZopeSimpleReadContainerDecorator(container)

class TestZopeReadContainerDecorator(TestZopeSimpleReadContainerDecorator,
                                     BaseTestIZopeReadContainer):

    def decorate(self, container):
        from zope.app.container.zopecontainer import \
            ZopeReadContainerDecorator
        return ZopeReadContainerDecorator(container)

class TestZopeItemWriteContainerDecorator(TestZopeItemContainerDecorator,
                                          BaseTestIZopeWriteContainer):
    # The ZopeItemWriteContainerDecorator depends on the container also being
    # an IItemContainer. It needs this to get values that are to be deleted
    # so they can be sent in events.
    # So, this unit test tests that the decorator implementation properly
    # decorates IZopeItemContainer and IZopeWriteContainer.

    def setUp(self):
        PlacelessSetup.setUp(self)
        from zope.app.container.sample import SampleContainer
        self._container = SampleContainer()

    def _sampleMapping(self):
        container = self._container
        for k, v in self._sampleDict().items():
            container.setObject(k, v)
        return self.decorate(container)

    def decorate(self, container):
        from zope.app.container.zopecontainer import \
            ZopeItemWriteContainerDecorator
        return ZopeItemWriteContainerDecorator(container)

    __newItem = {'A': C(), 'B':C()}
    def _sample_newItem(self):
        return self.__newItem

    __newItemHooked = {'B': H(), 'E':H()}
    def _sample_newItemHooked(self):
        return self.__newItemHooked


class TestZopeContainerDecorator(TestZopeItemWriteContainerDecorator,
                                 TestZopeReadContainerDecorator):

    def decorate(self, container):
        from zope.app.container.zopecontainer import ZopeContainerDecorator
        return ZopeContainerDecorator(container)


def test_suite():
    return TestSuite((
        makeSuite(TestZopeItemContainerDecorator),
        makeSuite(TestZopeSimpleReadContainerDecorator),
        makeSuite(TestZopeReadContainerDecorator),
        makeSuite(TestZopeItemWriteContainerDecorator),
        makeSuite(TestZopeContainerDecorator),
        ))

if __name__=='__main__':
    main(defaultTest='test_suite')


=== Zope3/src/zope/app/container/tests/baseizopeitemcontainer.py 1.3 => 1.3.18.1 ===
--- Zope3/src/zope/app/container/tests/baseizopeitemcontainer.py:1.3	Wed Feb 26 11:11:35 2003
+++ Zope3/src/zope/app/container/tests/baseizopeitemcontainer.py	Sun Jun 22 10:22:56 2003
@@ -17,7 +17,7 @@
 $Id$
 """
 
-from zope.proxy.context import getWrapperContainer, getWrapperData
+from zope.context import getWrapperContainer, getWrapperData
 from zope.interface.common.tests.basemapping \
      import BaseTestIReadMapping, BaseTestIEnumerableMapping
 from zope.app.event.tests.placelesssetup import getEvents
@@ -25,7 +25,6 @@
      import IObjectRemovedEvent, IObjectModifiedEvent, IObjectAddedEvent
 
 
-
 class BaseTestIZopeItemContainer:
 
     def _sampleMapping(self):
@@ -41,6 +40,7 @@
     def _absentKeys(self):
         """This should return the keys not in the container
         """
+        # XXX Is this supposed to be pseudocode? It doesn't make sense.
         absent_key = ''
         for key, value in testItems:
             absent_key += key


=== Zope3/src/zope/app/container/tests/test_containertraversable.py 1.4 => 1.4.10.1 ===
--- Zope3/src/zope/app/container/tests/test_containertraversable.py:1.4	Thu May  1 15:35:09 2003
+++ Zope3/src/zope/app/container/tests/test_containertraversable.py	Sun Jun 22 10:22:56 2003
@@ -21,11 +21,12 @@
 from zope.exceptions import NotFoundError
 from zope.app.interfaces.container import IContainer
 from zope.testing.cleanup import CleanUp
+from zope.interface import implements
 
 
 class Container:
 
-    __implements__ = IContainer
+    implements(IContainer)
 
     def __init__(self, attrs={}, objs={}):
         for attr,value in attrs.iteritems():


=== Zope3/src/zope/app/container/tests/test_containertraverser.py 1.7 => 1.7.10.1 ===
--- Zope3/src/zope/app/container/tests/test_containertraverser.py:1.7	Thu May  1 15:35:09 2003
+++ Zope3/src/zope/app/container/tests/test_containertraverser.py	Sun Jun 22 10:22:56 2003
@@ -21,7 +21,7 @@
 from zope.component import getService
 from zope.app.services.servicenames import Views
 from zope.app.container.traversal import ContainerTraverser
-from zope.interface import Interface
+from zope.interface import Interface, implements
 from zope.exceptions import NotFoundError
 from zope.app.interfaces.container import IContainer
 from zope.app.tests.placelesssetup import PlacelessSetup
@@ -31,7 +31,7 @@
 
 
 class Container:
-    __implements__ = IContainer
+    implements(IContainer)
 
     def __init__(self, **kw):
         for k in kw:


=== Zope3/src/zope/app/container/tests/test_find.py 1.3 => 1.3.10.1 ===
--- Zope3/src/zope/app/container/tests/test_find.py:1.3	Thu May  1 15:35:09 2003
+++ Zope3/src/zope/app/container/tests/test_find.py	Sun Jun 22 10:22:56 2003
@@ -20,11 +20,11 @@
 from unittest import TestCase, main, makeSuite
 from zope.app.interfaces.container import IReadContainer
 from zope.app.interfaces.container.find import IObjectFindFilter
-from zope.app.container.find\
-     import FindAdapter, SimpleIdFindFilter
+from zope.app.container.find import FindAdapter, SimpleIdFindFilter
+from zope.interface import implements
 
 class FakeContainer:
-    __implements__ = IReadContainer
+    implements(IReadContainer)
 
     def __init__(self, id, objects):
         self._id = id
@@ -62,7 +62,7 @@
         return len(self._objects)
 
 class TestObjectFindFilter(object):
-    __implements__ = IObjectFindFilter
+    implements(IObjectFindFilter)
 
     def __init__(self, count):
         self._count = count


=== Zope3/src/zope/app/container/tests/test_objectcopier.py 1.7 => 1.7.10.1 ===
--- Zope3/src/zope/app/container/tests/test_objectcopier.py:1.7	Thu May  1 15:35:09 2003
+++ Zope3/src/zope/app/container/tests/test_objectcopier.py	Sun Jun 22 10:22:56 2003
@@ -22,10 +22,8 @@
 from zope.app.services.tests.placefulsetup import PlacefulSetup
 from zope.component import getAdapter, ComponentLookupError
 from zope.component.adapter import provideAdapter
-from zope.app.traversing import IObjectName
-from zope.app.traversing.adapters import ObjectName
-from zope.app.interfaces.copypastemove import IObjectCopier, INoChildrenObjectCopier
-from zope.app.interfaces.content.folder import IFolder
+from zope.app.interfaces.copypastemove import IObjectCopier
+from zope.app.interfaces.copypastemove import INoChildrenObjectCopier
 from zope.app.interfaces.container import CopyException
 from zope.app.interfaces.container import IContainer
 from zope.app.interfaces.container import IPasteTarget
@@ -44,11 +42,10 @@
         PlacefulSetup.setUp(self)
         PlacefulSetup.buildFolders(self)
         provideAdapter(None, IObjectCopier, ObjectCopier)
-        provideAdapter(IFolder, IPasteTarget, PasteTarget)
-        provideAdapter(IFolder, ICopySource, CopySource)
-        provideAdapter(None, IObjectName, ObjectName)
-        provideAdapter(IFolder, IPasteNamesChooser, PasteNamesChooser)
- 
+        provideAdapter(IContainer, IPasteTarget, PasteTarget)
+        provideAdapter(IContainer, ICopySource, CopySource)
+        provideAdapter(IContainer, IPasteNamesChooser, PasteNamesChooser)
+
     def test_copytosame(self):
         root = self.rootFolder
         container = traverse(root, 'folder1')
@@ -171,15 +168,13 @@
         PlacefulSetup.setUp(self)
         PlacefulSetup.buildFolders(self)
         provideAdapter(None, IObjectCopier, ObjectCopier)
-        provideAdapter(IFolder, INoChildrenObjectCopier, NoChildrenObjectCopier)
-        provideAdapter(IContainer, INoChildrenObjectCopier, NoChildrenObjectCopier)
-        provideAdapter(IFolder, IPasteTarget, PasteTarget)
-        provideAdapter(IFolder, ICopySource, CopySource)
-        provideAdapter(IFolder, INoChildrenCopySource, NoChildrenCopySource)
+        provideAdapter(IContainer, INoChildrenObjectCopier,
+                       NoChildrenObjectCopier)
+        provideAdapter(IContainer, IPasteTarget, PasteTarget)
+        provideAdapter(IContainer, ICopySource, CopySource)
         provideAdapter(IContainer, INoChildrenCopySource, NoChildrenCopySource)
-        provideAdapter(None, IObjectName, ObjectName)
-        provideAdapter(IFolder, IPasteNamesChooser, PasteNamesChooser)
- 
+        provideAdapter(IContainer, IPasteNamesChooser, PasteNamesChooser)
+
     def test_copytosame(self):
         root = self.rootFolder
         container = traverse(root, 'folder1')
@@ -194,7 +189,8 @@
         container = traverse(root, 'folder1')
         container.setObject('file1', File())
         file = traverse(root, 'folder1/file1')
-        self.assertRaises(ComponentLookupError, getAdapter, file, INoChildrenObjectCopier)
+        self.assertRaises(ComponentLookupError,
+                          getAdapter, file, INoChildrenObjectCopier)
 
     def test_copytoother(self):
         root = self.rootFolder
@@ -211,7 +207,8 @@
         container = traverse(root, 'folder1')
         container.setObject('file1', File())
         file = traverse(root, 'folder1/file1')
-        self.assertRaises(ComponentLookupError, getAdapter, file, INoChildrenObjectCopier)
+        self.assertRaises(ComponentLookupError,
+                          getAdapter, file, INoChildrenObjectCopier)
 
     def test_doesntimplementclonewithoutchildren(self):
         root = self.rootFolder


=== Zope3/src/zope/app/container/tests/test_objectmover.py 1.5 => 1.5.10.1 ===
--- Zope3/src/zope/app/container/tests/test_objectmover.py:1.5	Thu May  1 15:35:09 2003
+++ Zope3/src/zope/app/container/tests/test_objectmover.py	Sun Jun 22 10:22:56 2003
@@ -22,8 +22,6 @@
 from zope.app.services.tests.placefulsetup import PlacefulSetup
 from zope.component import getAdapter
 from zope.component.adapter import provideAdapter
-from zope.app.traversing import IObjectName
-from zope.app.traversing.adapters import ObjectName
 from zope.app.interfaces.copypastemove import IObjectMover
 from zope.app.interfaces.content.folder import IFolder
 from zope.app.interfaces.container import IPasteTarget
@@ -43,7 +41,6 @@
         provideAdapter(None, IObjectMover, ObjectMover)
         provideAdapter(IFolder, IPasteTarget, PasteTarget)
         provideAdapter(IFolder, IMoveSource, MoveSource)
-        provideAdapter(None, IObjectName, ObjectName)
         provideAdapter(IFolder, IPasteNamesChooser, PasteNamesChooser)
  
     def test_movetosame(self):


=== Zope3/src/zope/app/container/tests/test_rename.py 1.4 => 1.4.10.1 ===
--- Zope3/src/zope/app/container/tests/test_rename.py:1.4	Thu May  1 15:35:09 2003
+++ Zope3/src/zope/app/container/tests/test_rename.py	Sun Jun 22 10:22:56 2003
@@ -22,8 +22,6 @@
 from zope.app.services.tests.placefulsetup import PlacefulSetup
 from zope.component import getAdapter
 from zope.component.adapter import provideAdapter
-from zope.app.traversing import IObjectName
-from zope.app.traversing.adapters import ObjectName
 from zope.app.interfaces.copypastemove import IObjectMover
 from zope.app.interfaces.container import IContainer
 from zope.app.interfaces.container import IPasteTarget
@@ -36,7 +34,6 @@
 from zope.app.copypastemove import ObjectMover
 from zope.app.content.file import File
 from zope.exceptions import NotFoundError, DuplicationError
-from zope.app.container.zopecontainer import ZopeContainerAdapter
 
 class RenameTest(PlacefulSetup, TestCase):
 
@@ -46,10 +43,8 @@
         provideAdapter(None, IObjectMover, ObjectMover)
         provideAdapter(IContainer, IPasteTarget, PasteTarget)
         provideAdapter(IContainer, IMoveSource, MoveSource)
-        provideAdapter(None, IObjectName, ObjectName)
         provideAdapter(IContainer, IPasteNamesChooser, PasteNamesChooser)
-        provideAdapter(IContainer, IZopeContainer, ZopeContainerAdapter)
- 
+
     def test_simplerename(self):
         root = self.rootFolder
         folder1 = traverse(root, 'folder1')
@@ -60,7 +55,6 @@
         self.failIf('file1' in container)
         self.failUnless('my_file1' in container)
 
-
     def test_renamenonexisting(self):
         root = self.rootFolder
         folder1 = traverse(root, 'folder1')
@@ -68,7 +62,6 @@
         container = getAdapter(folder1, IZopeContainer)
         self.assertRaises(NotFoundError, container.rename, \
                           'file1', 'my_file1')
-
 
     def test_renamesamename(self):
         root = self.rootFolder


=== Zope3/src/zope/app/container/tests/test_size.py 1.1 => 1.1.26.1 ===
--- Zope3/src/zope/app/container/tests/test_size.py:1.1	Fri Dec 27 13:22:58 2002
+++ Zope3/src/zope/app/container/tests/test_size.py	Sun Jun 22 10:22:56 2003
@@ -15,10 +15,11 @@
 
 from zope.app.interfaces.size import ISized
 from zope.app.interfaces.container import IContainer
+from zope.interface import implements
 
 class DummyContainer:
 
-    __implements__ = IContainer
+    implements(IContainer)
 
     def __init__(self, numitems):
         self._numitems = numitems

=== Removed File Zope3/src/zope/app/container/tests/test_zopecontaineradpter.py ===