[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Traversing/tests - __init__.py:1.1.2.1 testTraverser.py:1.1.2.1
Martijn Pieters
mj@zope.com
Mon, 3 Dec 2001 13:59:56 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Traversing/tests
In directory cvs.zope.org:/tmp/cvs-serv9562/lib/python/Zope/App/Traversing/tests
Added Files:
Tag: Zope-3x-branch
__init__.py testTraverser.py
Log Message:
Move traversing code to new package and rename the interface and class; this in
anticipation of related interfaces and code.
=== Added File Zope3/lib/python/Zope/App/Traversing/tests/__init__.py ===
"""App tests"""
=== Added File Zope3/lib/python/Zope/App/Traversing/tests/testTraverser.py ===
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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.
import unittest
from Zope.App.Traversing.ITraverser import ITraverser
from Zope.App.Traversing.Traverser import Traverser
from Zope.ContextWrapper import Wrapper
from Interface import verify, instancesOfObjectImplements
class C:
def __init__(self, name):
self.name = name
class TraverserTests(unittest.TestCase):
def setUp(self):
# Build up a wrapper chain
self.root = Wrapper(C('root'), None, name='')
self.folder = Wrapper(C('folder'), self.root, name='folder')
self.item = Wrapper(C('item'), self.folder, name='item')
self.tr = Traverser(self.item)
def testImplementsITraverser(self):
self.failUnless(ITraverser.isImplementedBy(self.tr))
def testVerifyInterfaces(self):
for interface in instancesOfObjectImplements(ITraverser):
verify(interface, ITraverser)
def testPhysicalRoot(self):
self.failUnless(self.tr.getPhysicalRoot() is self.root)
def testPhysicalPath(self):
self.assertEquals(self.tr.getPhysicalPath(), ('', 'folder', 'item'))
def testUnwrapped(self):
# The feature should do the right thing for unwrapped objects too
unwrapped = C('unwrapped')
tr = Traverser(unwrapped)
self.assertEquals(tr.getPhysicalPath(), ())
self.failUnless(tr.getPhysicalRoot() is unwrapped)
def test_suite():
loader = unittest.TestLoader()
return loader.loadTestsFromTestCase(TraverserTests)
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())