[Zope3-checkins]
CVS: Zope3/src/zope/products/demo/insensitivefolder - tests.py:1.3
Stephan Richter
srichter at cosmos.phy.tufts.edu
Fri Feb 13 22:01:49 EST 2004
Update of /cvs-repository/Zope3/src/zope/products/demo/insensitivefolder
In directory cvs.zope.org:/tmp/cvs-serv27114/src/zope/products/demo/insensitivefolder
Modified Files:
tests.py
Log Message:
Now I know where these aweful tests in the case-insensitive traverser came
from. They were just copied over from the default container traverser. So
I cleaned up the original tests and abstracted them a bit, so they can be
reused by other implementations. Removed unneccessary duplication of code
in the case-insensitive container traverser tests.
=== Zope3/src/zope/products/demo/insensitivefolder/tests.py 1.2 => 1.3 ===
--- Zope3/src/zope/products/demo/insensitivefolder/tests.py:1.2 Fri Feb 13 21:27:40 2004
+++ Zope3/src/zope/products/demo/insensitivefolder/tests.py Fri Feb 13 22:01:49 2004
@@ -16,26 +16,11 @@
$Id$
"""
import unittest
-from zope.app import zapi
-from zope.app.interfaces.container import IReadContainer
-from zope.app.tests import ztapi
-from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.component.tests.request import Request
-from zope.exceptions import NotFoundError
-from zope.interface import implements
-from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.app.container.tests import test_containertraverser
from zope.products.demo.insensitivefolder import \
CaseInsensitiveContainerTraverser
-class Container:
- implements(IReadContainer)
-
- def __init__(self, **kw):
- for k in kw:
- setattr(self, k , kw[k])
-
- def get(self, name, default=None):
- return getattr(self, name, default)
+class Container(test_containertraverser.TestContainer):
def keys(self):
return self.__dict__.keys()
@@ -44,51 +29,26 @@
return self.__dict__[name]
-class View:
- def __init__(self, context, request):
- self.context = context
- self.request = request
+class InsensitiveCaseTraverserTest(test_containertraverser.TraverserTest):
+ def _getTraverser(self, context, request):
+ return CaseInsensitiveContainerTraverser(context, request)
-class TraverserTest(PlacelessSetup, unittest.TestCase):
-
- def setUp(self):
- super(TraverserTest, self).setUp()
- self.foo = Container()
- foo2 = Container(foo=self.foo)
- self.request = Request(IBrowserRequest, '')
- self.traverser = CaseInsensitiveContainerTraverser(foo2, self.request)
- ztapi.browserView(IReadContainer, 'viewfoo', [View])
+ def _getContainer(self, **kw):
+ return Container(**kw)
- def test_itemTraversal(self):
+ def test_allLowerCaseItemTraversal(self):
self.assertEquals(
self.traverser.publishTraverse(self.request, 'foo'),
self.foo)
self.assertEquals(
self.traverser.publishTraverse(self.request, 'foO'),
self.foo)
- self.assertRaises(
- NotFoundError,
- self.traverser.publishTraverse, self.request, 'morebar')
-
- def test_viewTraversal(self):
- self.assertEquals(
- self.traverser.publishTraverse(self.request, 'viewfoo').__class__,
- View)
- self.assertEquals(
- self.traverser.publishTraverse(self.request, 'foo'),
- self.foo)
- self.assertRaises(
- NotFoundError,
- self.traverser.publishTraverse, self.request, 'morebar')
- self.assertRaises(
- NotFoundError,
- self.traverser.publishTraverse, self.request, '@@morebar')
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(TraverserTest),
+ unittest.makeSuite(InsensitiveCaseTraverserTest),
))
if __name__ == '__main__':
More information about the Zope3-Checkins
mailing list