[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/tests - testDefaultTraverser.py:1.1.2.7 testZopePublication.py:1.1.2.19
Stephan Richter
srichter@cbu.edu
Wed, 27 Mar 2002 17:31:57 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/tests
In directory cvs.zope.org:/tmp/cvs-serv1969/tests
Modified Files:
Tag: Zope-3x-branch
testDefaultTraverser.py testZopePublication.py
Log Message:
This is more of this bug fixing business. I basically started all over again. Atleast so far the tests pass.
=== Zope3/lib/python/Zope/App/ZopePublication/tests/testDefaultTraverser.py 1.1.2.6 => 1.1.2.7 ===
-#
-# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (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
-#
-##############################################################################
-"""
-
-$Id$
-"""
-
-import unittest, sys
-from Zope.ComponentArchitecture.tests.Request import Request
-from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
-from Zope.ComponentArchitecture import provideView
-from Zope.App.ZopePublication.Traversers import DefaultTraverser
-from Interface import Interface
-from Zope.Exceptions import NotFoundError
-
-
-class I(Interface): pass
-
-
-class Container:
-
- 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 Test(CleanUp, unittest.TestCase):
-
- def testAttr(self):
- """ test container traver """
-
- foo = Container()
- c = Container( foo=foo )
- req = Request( I, '')
-
- T = DefaultTraverser(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 = DefaultTraverser(c)
- provideView(None , '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())
-
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+import unittest, sys
+from Zope.ComponentArchitecture.tests.Request import Request
+from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
+from Zope.ComponentArchitecture import provideView
+from Zope.App.ZopePublication.Traversers import DefaultTraverser
+from Interface import Interface
+from Zope.Exceptions import NotFoundError
+
+
+class I(Interface): pass
+
+
+class Container:
+
+ 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 Test(CleanUp, unittest.TestCase):
+
+ def testAttr(self):
+ """ test container traver """
+
+ foo = Container()
+ c = Container( foo=foo )
+ req = Request( I, '')
+
+ T = DefaultTraverser(c)
+ self.failUnless(T.browser_traverse(req,'foo') is foo)
+
+ self.assertRaises(NotFoundError , T.browser_traverse, req ,'morebar')
+
+
+ def testView(self):
+ """ test getting a view """
+
+
+ foo = Container()
+ c = Container( foo=foo )
+ req = Request( I, '')
+
+ T = DefaultTraverser(c)
+ provideView(None , 'foo', I, View)
+
+ self.failUnless(T.browser_traverse(req,'foo;view').__class__ is View )
+ self.failUnless(T.browser_traverse(req,'foo') is foo)
+
+ self.assertRaises(NotFoundError , T.browser_traverse, req ,'morebar')
+ self.assertRaises(NotFoundError , T.browser_traverse, req ,
+ 'morebar;view')
+
+
+
+def test_suite():
+ loader=unittest.TestLoader()
+ return loader.loadTestsFromTestCase(Test)
+
+if __name__=='__main__':
+ unittest.TextTestRunner().run(test_suite())
=== Zope3/lib/python/Zope/App/ZopePublication/tests/testZopePublication.py 1.1.2.18 => 1.1.2.19 ===
__implements__ = IBrowserPublisher
- def publishTraverse(self, request, name):
+ def browser_traverse(self, request, name):
if name == 'bruce':
return foo
raise KeyError, name
- def browserDefault(self, request):
+ def browser_default(self, request):
return self, ['bruce']
class DummyView(DummyPublished):
@@ -210,7 +210,7 @@
self.context = context
self.counter = 0
- def publishTraverse(self, request, name):
+ def browser_traverse(self, request, name):
self.counter+=1
return self.context[name]
@@ -238,7 +238,7 @@
def __init__(self, context):
self.context = context
- def browserDefault(self, request):
+ def browser_default(self, request):
return (self.context['bruce'], 'dummy')
provideView(I1, '_traverse', IBrowserPublisher, Adapter)
@@ -317,4 +317,3 @@
if __name__=='__main__':
unittest.TextTestRunner().run( test_suite() )
-