[Zope3-checkins] CVS: Zope3/src/zope/app/container/tests - test_objectcopier.py:1.1.2.1 test_objectmover.py:1.1.2.6
Sidnei da Silva
sidnei@x3ng.com.br
Wed, 5 Feb 2003 05:09:49 -0500
Update of /cvs-repository/Zope3/src/zope/app/container/tests
In directory cvs.zope.org:/tmp/cvs-serv3236/src/zope/app/container/tests
Modified Files:
Tag: paris-copypasterename-branch
test_objectmover.py
Added Files:
Tag: paris-copypasterename-branch
test_objectcopier.py
Log Message:
Fixing ObjectMover tests. Adding ObjectCopier tests. Adding AnnotatableUserClipboard with tests. That was a productive night :)
=== Added File Zope3/src/zope/app/container/tests/test_objectcopier.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.
#
##############################################################################
"""
Revision information:
$Id: test_objectcopier.py,v 1.1.2.1 2003/02/05 10:09:15 sidnei Exp $
"""
from unittest import TestCase, TestSuite, main, makeSuite
from zope.app.traversing import traverse
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.copy import IObjectCopier
from zope.app.interfaces.content.folder import IFolder
from zope.app.interfaces.container import IPasteTarget
from zope.app.interfaces.container import ICopySource
from zope.app.interfaces.container import IPasteNamesChooser
from zope.app.container.copy import PasteTarget
from zope.app.container.copy import CopySource
from zope.app.container.copy import PasteNamesChooser
from zope.app.copy import ObjectCopier
from zope.app.content.folder import Folder
from zope.app.content.file import File
class ObjectCopierTest(PlacefulSetup, TestCase):
def setUp(self):
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)
def test_copytosame(self):
root = self.rootFolder
container = traverse(root, 'folder1')
container.setObject('file1', File())
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
copier.copyTo(container, 'file1')
self.failUnless('file1' in container)
self.failUnless('copy_of_file1' in container)
def test_copytosamewithnewname(self):
root = self.rootFolder
container = traverse(root, 'folder1')
container.setObject('file1', File())
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
copier.copyTo(container, 'file2')
self.failUnless('file1' in container)
self.failUnless('file2' in container)
def test_copytoother(self):
root = self.rootFolder
container = traverse(root, 'folder1')
container.setObject('file1', File())
target = traverse(root, 'folder2')
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
copier.copyTo(target, 'file1')
self.failUnless('file1' in container)
self.failUnless('file1' in target)
def test_copytootherwithnewname(self):
root = self.rootFolder
container = traverse(root, 'folder1')
container.setObject('file1', File())
target = traverse(root, 'folder2')
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
copier.copyTo(target, 'file2')
self.failUnless('file1' in container)
self.failUnless('file2' in target)
def test_copytootherwithnamecollision(self):
root = self.rootFolder
container = traverse(root, 'folder1')
container.setObject('file1', File())
target = traverse(root, 'folder2')
target.setObject('file1', File())
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
copier.copyTo(target, 'file1')
# we do it twice, just to test auto-name generation
copier.copyTo(target, 'file1')
self.failUnless('file1' in container)
self.failUnless('file1' in target)
self.failUnless('copy_of_file1' in target)
self.failUnless('copy2_of_file1' in target)
def test_copyable(self):
root = self.rootFolder
container = traverse(root, 'folder1')
container.setObject('file1', File())
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
self.failUnless(copier.copyable())
def test_copyableTo(self):
# A file should be copyable to a folder that has an
# object with the same id.
root = self.rootFolder
container = traverse(root, 'folder1')
container.setObject('file1', File())
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
self.failUnless(copier.copyableTo(container, 'file1'))
def test_suite():
return TestSuite((
makeSuite(ObjectCopierTest),
))
if __name__=='__main__':
main(defaultTest='test_suite')
=== Zope3/src/zope/app/container/tests/test_objectmover.py 1.1.2.5 => 1.1.2.6 ===
--- Zope3/src/zope/app/container/tests/test_objectmover.py:1.1.2.5 Tue Feb 4 12:06:25 2003
+++ Zope3/src/zope/app/container/tests/test_objectmover.py Wed Feb 5 05:09:15 2003
@@ -24,12 +24,15 @@
from zope.component.adapter import provideAdapter
from zope.app.traversing import IObjectName
from zope.app.traversing.adapters import ObjectName
-from zope.app.interfaces.copy import IObjectMover, IObjectCopier
+from zope.app.interfaces.copy import IObjectMover
+from zope.app.interfaces.content.folder import IFolder
from zope.app.interfaces.container import IPasteTarget
from zope.app.interfaces.container import IMoveSource
+from zope.app.interfaces.container import IPasteNamesChooser
from zope.app.container.copy import PasteTarget
from zope.app.container.copy import MoveSource
-from zope.app.copy import ObjectMover, ObjectCopier
+from zope.app.container.copy import PasteNamesChooser
+from zope.app.copy import ObjectMover
from zope.app.content.folder import Folder
from zope.app.content.file import File
@@ -39,21 +42,65 @@
PlacefulSetup.setUp(self)
PlacefulSetup.buildFolders(self)
provideAdapter(None, IObjectMover, ObjectMover)
- provideAdapter(None, IPasteTarget, PasteTarget)
- provideAdapter(None, IMoveSource, MoveSource)
+ provideAdapter(IFolder, IPasteTarget, PasteTarget)
+ provideAdapter(IFolder, IMoveSource, MoveSource)
provideAdapter(None, IObjectName, ObjectName)
+ provideAdapter(IFolder, IPasteNamesChooser, PasteNamesChooser)
- def test_moveto(self):
+ def test_movetosame(self):
+ root = self.rootFolder
+ container = traverse(root, 'folder1')
+ container.setObject('file1', File())
+ file = traverse(root, 'folder1/file1')
+ mover = getAdapter(file, IObjectMover)
+ mover.moveTo(container, 'file1')
+ self.failUnless('file1' in container)
+
+ def test_movetosamewithnewname(self):
root = self.rootFolder
container = traverse(root, 'folder1')
container.setObject('file1', File())
file = traverse(root, 'folder1/file1')
mover = getAdapter(file, IObjectMover)
- #paster = getAdapter(container, IPasteTarget)
mover.moveTo(container, 'file2')
self.failIf('file1' in container)
self.failUnless('file2' in container)
+ def test_movetoother(self):
+ root = self.rootFolder
+ container = traverse(root, 'folder1')
+ container.setObject('file1', File())
+ target = traverse(root, 'folder2')
+ file = traverse(root, 'folder1/file1')
+ mover = getAdapter(file, IObjectMover)
+ mover.moveTo(target, 'file1')
+ self.failIf('file1' in container)
+ self.failUnless('file1' in target)
+
+ def test_movetootherwithnewname(self):
+ root = self.rootFolder
+ container = traverse(root, 'folder1')
+ container.setObject('file1', File())
+ target = traverse(root, 'folder2')
+ file = traverse(root, 'folder1/file1')
+ mover = getAdapter(file, IObjectMover)
+ mover.moveTo(target, 'file2')
+ self.failIf('file1' in container)
+ self.failUnless('file2' in target)
+
+ def test_movetootherwithnamecollision(self):
+ root = self.rootFolder
+ container = traverse(root, 'folder1')
+ container.setObject('file1', File())
+ target = traverse(root, 'folder2')
+ target.setObject('file1', File())
+ file = traverse(root, 'folder1/file1')
+ mover = getAdapter(file, IObjectMover)
+ mover.moveTo(target, 'file1')
+ self.failIf('file1' in container)
+ self.failUnless('file1' in target)
+ self.failUnless('copy_of_file1' in target)
+
def test_moveable(self):
root = self.rootFolder
container = traverse(root, 'folder1')
@@ -63,14 +110,14 @@
self.failUnless(mover.moveable())
def test_moveableTo(self):
- # A file should not be moveable in its same folder.
- #
+ # A file should be moveable to a folder that has an
+ # object with the same id.
root = self.rootFolder
container = traverse(root, 'folder1')
container.setObject('file1', File())
file = traverse(root, 'folder1/file1')
mover = getAdapter(file, IObjectMover)
- self.failIf(mover.moveableTo(container, 'file1'))
+ self.failUnless(mover.moveableTo(container, 'file1'))
def test_suite():
return TestSuite((