[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Traversing/tests - testConvenienceFunctions.py:1.2
Steve Alexander
steve@cat-box.net
Tue, 18 Jun 2002 18:14:17 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Traversing/tests
In directory cvs.zope.org:/tmp/cvs-serv3588/lib/python/Zope/App/Traversing/tests
Modified Files:
testConvenienceFunctions.py
Log Message:
added traverseName convenience function.
=== Zope3/lib/python/Zope/App/Traversing/tests/testConvenienceFunctions.py 1.1 => 1.2 ===
from Zope.App.Traversing.DefaultTraversable import DefaultTraversable
from Zope.App.Traversing.ObjectName import IObjectName, ObjectName
+from Zope.Exceptions import NotFoundError
class C:
def __init__(self, name):
@@ -70,7 +71,45 @@
traverse,
self.unwrapped_item, '/folder/item'
)
-
+
+ def testTraverseName(self):
+ from Zope.App.Traversing import traverseName
+ self.assertEqual(
+ traverseName(self.folder, 'item'),
+ self.tr.traverse('/folder/item')
+ )
+ self.assertEqual(
+ traverseName(self.item, '.'),
+ self.tr.traverse('/folder/item')
+ )
+
+
+ def testTraverseNameUnwrapped(self):
+ from Zope.App.Traversing import traverseName
+ self.assertRaises(
+ TypeError,
+ traverseName,
+ self.unwrapped_item, 'item'
+ )
+
+ def testTraverseNameBadValue(self):
+ from Zope.App.Traversing import traverseName
+ self.assertRaises(
+ NotFoundError,
+ traverseName,
+ self.folder, '../root'
+ )
+ self.assertRaises(
+ NotFoundError,
+ traverseName,
+ self.folder, '/root'
+ )
+ self.assertRaises(
+ NotFoundError,
+ traverseName,
+ self.folder, './item'
+ )
+
def testObjectName(self):
from Zope.App.Traversing import objectName
self.assertEqual(