[Zope3-checkins] CVS: Zope3/src/zope/app/traversing/tests - test_conveniencefunctions.py:1.4

Steve Alexander steve@cat-box.net
Sat, 28 Dec 2002 10:20:51 -0500


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

Modified Files:
	test_conveniencefunctions.py 
Log Message:
Improved the semantics of getParent and getParents.
Removed XXX comment in traverse regarding the 'request' argument, and
moved the explanation of it into the docstring for traverse.
Removed asserts from locationAsXXXX functions and replaced them with
raising ValueError.


=== Zope3/src/zope/app/traversing/tests/test_conveniencefunctions.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/traversing/tests/test_conveniencefunctions.py:1.3	Sat Dec 28 09:13:29 2002
+++ Zope3/src/zope/app/traversing/tests/test_conveniencefunctions.py	Sat Dec 28 10:20:50 2002
@@ -15,16 +15,15 @@
 
 $Id$
 """
-from unittest import TestCase, TestSuite, main, makeSuite
+from unittest import TestCase, main, makeSuite
 from zope.app.services.tests.placefulsetup import PlacefulSetup
 from zope.proxy.context import ContextWrapper
 from zope.app.traversing.traverser import Traverser
 from zope.component import getService
-
-from zope.app.interfaces.traversing import ITraverser
-from zope.app.interfaces.traversing import ITraversable
+from zope.app.interfaces.traversing import ITraverser, ITraversable
+from zope.app.interfaces.traversing import IObjectName
 from zope.app.traversing.defaulttraversable import DefaultTraversable
-from zope.app.traversing.objectname import IObjectName, ObjectName
+from zope.app.traversing.objectname import ObjectName
 
 from zope.app.interfaces.traversing import IPhysicallyLocatable
 from zope.app.interfaces.traversing import IContainmentRoot
@@ -54,11 +53,15 @@
         folder = C('folder')
         item = C('item')
 
-        self.root =   ContextWrapper(root, None)
+        self.root = root  # root is not usually wrapped
         self.folder = ContextWrapper(folder, self.root,   name='folder')
         self.item =   ContextWrapper(item,   self.folder, name='item')
         self.unwrapped_item = item
-
+        self.broken_chain_folder = ContextWrapper(folder, None)
+        self.broken_chain_item = ContextWrapper(item, 
+                                    self.broken_chain_folder,
+                                    name='item'
+                                    )
         root.folder = folder
         folder.item = item
 
@@ -141,6 +144,21 @@
             self.folder
             )
 
+    def testGetParentFromRoot(self):
+        from zope.app.traversing import getParent
+        self.assertEqual(
+            getParent(self.root),
+            None
+            )
+
+    def testGetParentBrokenChain(self):
+        from zope.app.traversing import getParent
+        self.assertRaises(
+            TypeError,
+            getParent,
+            self.broken_chain_folder
+            )
+
     def testGetParentFromUnwrapped(self):
         from zope.app.traversing import getParent
         self.assertRaises(
@@ -156,6 +174,13 @@
             [self.folder, self.root]
             )
 
+    def testGetParentsBrokenChain(self):
+        from zope.app.traversing import getParents
+        self.assertRaises(
+            TypeError,
+            getParents,
+            self.broken_chain_item
+            )
 
     def testGetParentsFromUnwrapped(self):
         from zope.app.traversing import getParents
@@ -215,7 +240,7 @@
         (ValueError, 23),
         (ValueError, ''),
         (ValueError, '//'),
-##        (AssertionError, '/foo//bar'),
+        (ValueError, '/foo//bar'),
 
         # regarding the next four errors:
         # having a trailing slash on a location is undefined.