[Zope3-checkins] CVS: Zope3/src/zope/app/container/tests - test_rename.py:1.2

Sidnei da Silva sidnei@x3ng.com.br
Tue, 11 Feb 2003 14:53:37 -0500


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

Modified Files:
	test_rename.py 
Log Message:
Adding new tests to ZopeContainerAdapter rename method. Sorry for commiting broken tests

=== Zope3/src/zope/app/container/tests/test_rename.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/container/tests/test_rename.py:1.1	Tue Feb 11 13:04:16 2003
+++ Zope3/src/zope/app/container/tests/test_rename.py	Tue Feb 11 14:53:36 2003
@@ -27,15 +27,16 @@
 from zope.app.interfaces.copy import IObjectMover
 from zope.app.interfaces.container import IContainer
 from zope.app.interfaces.container import IPasteTarget
-from zope.app.interfaces.container import ICopySource
+from zope.app.interfaces.container import IMoveSource
 from zope.app.interfaces.container import IPasteNamesChooser
 from zope.app.interfaces.container import IZopeContainer
 from zope.app.container.copy import PasteTarget
-from zope.app.container.copy import CopySource
+from zope.app.container.copy import MoveSource
 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
+from zope.exceptions import NotFoundError, DuplicationError
 from zope.app.container.zopecontainer \
      import ZopeContainerAdapter
 
@@ -46,18 +47,41 @@
         PlacefulSetup.buildFolders(self)
         provideAdapter(None, IObjectMover, ObjectMover)
         provideAdapter(IContainer, IPasteTarget, PasteTarget)
-        provideAdapter(IContainer, ICopySource, CopySource)
+        provideAdapter(IContainer, IMoveSource, MoveSource)
         provideAdapter(None, IObjectName, ObjectName)
         provideAdapter(IContainer, IPasteNamesChooser, PasteNamesChooser)
         provideAdapter(IContainer, IZopeContainer, ZopeContainerAdapter)
  
     def test_simplerename(self):
         root = self.rootFolder
-        f1 = traverse(root, 'folder1')
-        container = getAdapter(f1, IZopeContainer)
-        container.rename('folder1', 'my_folder1')
-        self.failIf('folder1' in container)
-        self.failUnless('my_folder1' in container)
+        folder1 = traverse(root, 'folder1')
+        self.failIf('file1' in folder1)
+        folder1.setObject('file1', File())
+        container = getAdapter(folder1, IZopeContainer)
+        container.rename('file1', 'my_file1')
+        self.failIf('file1' in container)
+        self.failUnless('my_file1' in container)
+
+
+    def test_renamenonexisting(self):
+        root = self.rootFolder
+        folder1 = traverse(root, 'folder1')
+        self.failIf('a_test_file' in folder1)
+        container = getAdapter(folder1, IZopeContainer)
+        self.assertRaises(NotFoundError, container.rename, \
+                          'file1', 'my_file1')
+
+
+    def test_renamesamename(self):
+        root = self.rootFolder
+        folder1 = traverse(root, 'folder1')
+        self.failIf('file1' in folder1)
+        self.failIf('file2' in folder1)
+        folder1.setObject('file1', File())
+        folder1.setObject('file2', File())
+        container = getAdapter(folder1, IZopeContainer)
+        self.assertRaises(DuplicationError, container.rename, \
+                          'file1', 'file2')
 
 def test_suite():
     return TestSuite((