[Zope3-checkins] CVS: Zope3/src/zope/app/container/tests -
test_objectcopier.py:1.10
Jim Fulton
jim at zope.com
Sun Sep 21 13:31:41 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/container/tests
In directory cvs.zope.org:/tmp/cvs-serv13356/src/zope/app/container/tests
Modified Files:
test_objectcopier.py
Log Message:
Changed to use __setitem__ rather than setObject
Got rid of the "target" and "source" adapters.
Got rid of the NoChildrenObjectCopier.
=== Zope3/src/zope/app/container/tests/test_objectcopier.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/container/tests/test_objectcopier.py:1.9 Fri Jun 13 13:41:14 2003
+++ Zope3/src/zope/app/container/tests/test_objectcopier.py Sun Sep 21 13:31:41 2003
@@ -23,16 +23,8 @@
from zope.component import getAdapter, ComponentLookupError
from zope.component.adapter import provideAdapter
from zope.app.interfaces.copypastemove import IObjectCopier
-from zope.app.interfaces.copypastemove import INoChildrenObjectCopier
-from zope.app.interfaces.container import CopyException
+from zope.app.copypastemove import ObjectCopier
from zope.app.interfaces.container import IContainer
-from zope.app.interfaces.container import IPasteTarget
-from zope.app.interfaces.container import ICopySource, INoChildrenCopySource
-from zope.app.interfaces.container import IPasteNamesChooser
-from zope.app.container.copypastemove import PasteTarget
-from zope.app.container.copypastemove import CopySource, NoChildrenCopySource
-from zope.app.container.copypastemove import PasteNamesChooser
-from zope.app.copypastemove import ObjectCopier, NoChildrenObjectCopier
from zope.app.content.file import File
from zope.app.container.sample import SampleContainer
@@ -42,24 +34,21 @@
PlacefulSetup.setUp(self)
PlacefulSetup.buildFolders(self)
provideAdapter(None, IObjectCopier, ObjectCopier)
- provideAdapter(IContainer, IPasteTarget, PasteTarget)
- provideAdapter(IContainer, ICopySource, CopySource)
- provideAdapter(IContainer, IPasteNamesChooser, PasteNamesChooser)
def test_copytosame(self):
root = self.rootFolder
container = traverse(root, 'folder1')
- container.setObject('file1', File())
+ container['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)
+ self.failUnless('file1-2' in container)
def test_copytosamewithnewname(self):
root = self.rootFolder
container = traverse(root, 'folder1')
- container.setObject('file1', File())
+ container['file1'] = File()
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
copier.copyTo(container, 'file2')
@@ -69,7 +58,7 @@
def test_copytoother(self):
root = self.rootFolder
container = traverse(root, 'folder1')
- container.setObject('file1', File())
+ container['file1'] = File()
target = traverse(root, 'folder2')
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
@@ -80,7 +69,7 @@
def test_copytootherwithnewname(self):
root = self.rootFolder
container = traverse(root, 'folder1')
- container.setObject('file1', File())
+ container['file1'] = File()
target = traverse(root, 'folder2')
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
@@ -91,9 +80,9 @@
def test_copytootherwithnamecollision(self):
root = self.rootFolder
container = traverse(root, 'folder1')
- container.setObject('file1', File())
+ container['file1'] = File()
target = traverse(root, 'folder2')
- target.setObject('file1', File())
+ target['file1'] = File()
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
copier.copyTo(target, 'file1')
@@ -101,13 +90,13 @@
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)
+ self.failUnless('file1-2' in target)
+ self.failUnless('file1-3' in target)
def test_copyable(self):
root = self.rootFolder
container = traverse(root, 'folder1')
- container.setObject('file1', File())
+ container['file1'] = File()
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
self.failUnless(copier.copyable())
@@ -117,7 +106,7 @@
# object with the same id.
root = self.rootFolder
container = traverse(root, 'folder1')
- container.setObject('file1', File())
+ container['file1'] = File()
file = traverse(root, 'folder1/file1')
copier = getAdapter(file, IObjectCopier)
self.failUnless(copier.copyableTo(container, 'file1'))
@@ -162,65 +151,9 @@
copier.copyTo(target)
self.failUnless('folder1' in target)
-class NoChildrenObjectCopierTest(PlacefulSetup, TestCase):
-
- def setUp(self):
- PlacefulSetup.setUp(self)
- PlacefulSetup.buildFolders(self)
- provideAdapter(None, IObjectCopier, ObjectCopier)
- provideAdapter(IContainer, INoChildrenObjectCopier,
- NoChildrenObjectCopier)
- provideAdapter(IContainer, IPasteTarget, PasteTarget)
- provideAdapter(IContainer, ICopySource, CopySource)
- provideAdapter(IContainer, INoChildrenCopySource, NoChildrenCopySource)
- provideAdapter(IContainer, IPasteNamesChooser, PasteNamesChooser)
-
- def test_copytosame(self):
- root = self.rootFolder
- container = traverse(root, 'folder1')
- folder1 = traverse(root, 'folder1')
- copier = getAdapter(folder1, INoChildrenObjectCopier)
- copier.copyTo(container, 'new_folder1')
- new_folder1 = traverse(container, 'new_folder1')
- self.assertEquals(len(new_folder1.keys()), 0)
-
- def test_notavailforfile(self):
- root = self.rootFolder
- container = traverse(root, 'folder1')
- container.setObject('file1', File())
- file = traverse(root, 'folder1/file1')
- self.assertRaises(ComponentLookupError,
- getAdapter, file, INoChildrenObjectCopier)
-
- def test_copytoother(self):
- root = self.rootFolder
- container = traverse(root, 'folder1')
- target = traverse(root, 'folder2')
- folder1_1 = traverse(root, 'folder1/folder1_1')
- copier = getAdapter(folder1_1, INoChildrenObjectCopier)
- copier.copyTo(target, 'folder1_1')
- new_folder1_1 = traverse(root, 'folder2/folder1_1')
- self.assertEquals(len(new_folder1_1.keys()), 0)
-
- def test_notavailforfile(self):
- root = self.rootFolder
- container = traverse(root, 'folder1')
- container.setObject('file1', File())
- file = traverse(root, 'folder1/file1')
- self.assertRaises(ComponentLookupError,
- getAdapter, file, INoChildrenObjectCopier)
-
- def test_doesntimplementclonewithoutchildren(self):
- root = self.rootFolder
- root.setObject('sample', SampleContainer())
- folder = traverse(root, 'sample')
- copier = getAdapter(folder, INoChildrenObjectCopier)
- self.assertRaises(CopyException, copier.copyTo, root, 'new_sample')
-
def test_suite():
return TestSuite((
makeSuite(ObjectCopierTest),
- makeSuite(NoChildrenObjectCopierTest),
))
if __name__=='__main__':
More information about the Zope3-Checkins
mailing list