[Zope3-checkins] CVS: Zope3/src/zope/app/tests - test_rename.py:1.2
Jim Fulton
jim at zope.com
Sun Sep 21 13:33:38 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/tests
In directory cvs.zope.org:/tmp/cvs-serv15504/src/zope/app/tests
Added Files:
test_rename.py
Log Message:
Moved rename support to app/copypastemove.
=== Zope3/src/zope/app/tests/test_rename.py 1.1 => 1.2 ===
--- /dev/null Sun Sep 21 13:33:38 2003
+++ Zope3/src/zope/app/tests/test_rename.py Sun Sep 21 13:33:38 2003
@@ -0,0 +1,69 @@
+##############################################################################
+#
+# 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$
+"""
+
+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.interfaces.copypastemove import IObjectMover
+from zope.app.interfaces.container import IContainer
+from zope.app.copypastemove import ObjectMover
+from zope.app.content.file import File
+from zope.exceptions import NotFoundError, DuplicationError
+from zope.app.copypastemove import rename
+
+class RenameTest(PlacefulSetup, TestCase):
+
+ def setUp(self):
+ PlacefulSetup.setUp(self)
+ PlacefulSetup.buildFolders(self)
+ provideAdapter(None, IObjectMover, ObjectMover)
+
+ def test_simplerename(self):
+ root = self.rootFolder
+ folder1 = traverse(root, 'folder1')
+ self.failIf('file1' in folder1)
+ folder1['file1'] = File()
+ rename(folder1, 'file1', 'my_file1')
+ self.failIf('file1' in folder1)
+ self.failUnless('my_file1' in folder1)
+
+ def test_renamenonexisting(self):
+ root = self.rootFolder
+ folder1 = traverse(root, 'folder1')
+ self.failIf('a_test_file' in folder1)
+ self.assertRaises(NotFoundError, rename, folder1, '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['file1'] = File()
+ folder1['file2'] = File()
+ self.assertRaises(DuplicationError, rename, folder1, 'file1', 'file2')
+
+def test_suite():
+ return TestSuite((
+ makeSuite(RenameTest),
+ ))
+
+if __name__=='__main__':
+ main(defaultTest='test_suite')
More information about the Zope3-Checkins
mailing list