[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/tests - testContainerTraverser.py:1.1.2.5.8.1
Jim Fulton
jim@zope.com
Wed, 29 May 2002 11:10:09 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/tests
In directory cvs.zope.org:/tmp/cvs-serv12181/lib/python/Zope/App/OFS/Container/tests
Modified Files:
Tag: Zope3InWonderland-branch
testContainerTraverser.py
Log Message:
- Added permission_id attribute to adapter and utility directives.
- Got rid of old getView, getResource, and getDefaultViewName.
Renamed getRequestView to getView (and so on).
Changed view interface to use context, rather than getContext.
Introduced notion of presentation types (e.g. IBrowserPresentation,
which is cleaner than IBrowserPublisher).
- Began converting to get/queryFoo, which is much nicer.
- Many formatting fixups.
=== Zope3/lib/python/Zope/App/OFS/Container/tests/testContainerTraverser.py 1.1.2.5 => 1.1.2.5.8.1 ===
$Id$
-"""
+"""
-import unittest, sys
-from Zope.ComponentArchitecture.tests.Request import Request
+import unittest, sys
+from Zope.ComponentArchitecture.tests.Request import Request
from Zope.ComponentArchitecture import getService
-from Zope.App.OFS.Container.ContainerTraverser import ContainerTraverser
-from Interface import Interface
-from Zope.Exceptions import NotFoundError
+from Zope.App.OFS.Container.ContainerTraverser import ContainerTraverser
+from Interface import Interface
+from Zope.Exceptions import NotFoundError
from Zope.App.OFS.Container.IContainer import IContainer
from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
-
-
-class I(Interface): pass
-
-
-class Container:
-
- __implements__ = IContainer
-
- def __init__(self, **kw):
-
- for k in kw:
- setattr(self, k , kw[k])
-
-
- def getObject(self, name, default=None):
-
- return getattr(self, name, default)
-
-
-
-class Request(Request):
-
- def getEffectiveURL(self):
- return ''
-
-class View:
-
- def __init__(self, comp):
- self._comp = comp
-
-
-
+
+
+class I(Interface): pass
+
+
+class Container:
+
+ __implements__ = IContainer
+
+ def __init__(self, **kw):
+
+ for k in kw:
+ setattr(self, k , kw[k])
+
+
+ def getObject(self, name, default=None):
+
+ return getattr(self, name, default)
+
+
+
+class Request(Request):
+
+ def getEffectiveURL(self):
+ return ''
+
+class View:
+
+ def __init__(self, comp, request):
+ self._comp = comp
+
+
+
class Test(PlacelessSetup, unittest.TestCase):
- def testAttr(self):
- """ test container traver """
-
- foo = Container()
- c = Container( foo=foo )
- req = Request( I, '')
-
- T = ContainerTraverser(c)
- self.failUnless(T.publishTraverse(req,'foo') is foo)
-
- self.assertRaises(NotFoundError , T.publishTraverse, req ,'morebar')
-
-
- def testView(self):
- """ test getting a view """
-
-
- foo = Container()
- c = Container( foo=foo )
- req = Request( I, '')
-
- T = ContainerTraverser(c)
- getService(None,'Views').provideView(IContainer, 'foo', I, View)
-
- self.failUnless(T.publishTraverse(req,'foo;view').__class__ is View )
- self.failUnless(T.publishTraverse(req,'foo') is foo)
-
- self.assertRaises(NotFoundError , T.publishTraverse, req, 'morebar')
- self.assertRaises(NotFoundError , T.publishTraverse, req,
- 'morebar;view')
-
-
-
-
-def test_suite():
- loader=unittest.TestLoader()
- return loader.loadTestsFromTestCase(Test)
-
-if __name__=='__main__':
- unittest.TextTestRunner().run(test_suite())
+ def testAttr(self):
+ """ test container traver """
+
+ foo = Container()
+ c = Container( foo=foo )
+ req = Request( I, '')
+
+ T = ContainerTraverser(c)
+ self.failUnless(T.publishTraverse(req,'foo') is foo)
+
+ self.assertRaises(NotFoundError , T.publishTraverse, req ,'morebar')
+
+
+ def testView(self):
+ """ test getting a view """
+
+
+ foo = Container()
+ c = Container( foo=foo )
+ req = Request( I, '')
+
+ T = ContainerTraverser(c)
+ getService(None,'Views').provideView(IContainer, 'foo', I, [View])
+
+ self.failUnless(T.publishTraverse(req,'foo;view').__class__ is View )
+ self.failUnless(T.publishTraverse(req,'foo') is foo)
+
+ self.assertRaises(NotFoundError , T.publishTraverse, req, 'morebar')
+ self.assertRaises(NotFoundError , T.publishTraverse, req,
+ 'morebar;view')
+
+
+
+
+def test_suite():
+ loader=unittest.TestLoader()
+ return loader.loadTestsFromTestCase(Test)
+
+if __name__=='__main__':
+ unittest.TextTestRunner().run(test_suite())