[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/tests - testDefaultTraverser.py:1.1.2.4 testZopePublication.py:1.1.2.15
Jim Fulton
jim@zope.com
Tue, 26 Mar 2002 16:26:27 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/tests
In directory cvs.zope.org:/tmp/cvs-serv7731/Zope/App/ZopePublication/tests
Modified Files:
Tag: Zope-3x-branch
testDefaultTraverser.py testZopePublication.py
Log Message:
Merged the publication refactoring branch into the main branch.
Also renamed:
browser_reaverse -> publishTraverse
browser_default -> browserDefault
=== Zope3/lib/python/Zope/App/ZopePublication/tests/testDefaultTraverser.py 1.1.2.3 => 1.1.2.4 ===
T = DefaultTraverser(c)
- self.failUnless(T.browser_traverse(req,'foo') is foo)
+ self.failUnless(T.publishTraverse(req,'foo') is foo)
- self.assertRaises(NotFoundError , T.browser_traverse, req ,'morebar')
+ self.assertRaises(NotFoundError , T.publishTraverse, req ,'morebar')
def testView(self):
@@ -79,11 +79,11 @@
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.failUnless(T.publishTraverse(req,'foo;view').__class__ is View )
+ self.failUnless(T.publishTraverse(req,'foo') is foo)
- self.assertRaises(NotFoundError , T.browser_traverse, req ,'morebar')
- self.assertRaises(NotFoundError , T.browser_traverse, req ,
+ self.assertRaises(NotFoundError , T.publishTraverse, req ,'morebar')
+ self.assertRaises(NotFoundError , T.publishTraverse, req ,
'morebar;view')
=== Zope3/lib/python/Zope/App/ZopePublication/tests/testZopePublication.py 1.1.2.14 => 1.1.2.15 ===
from Zope.Publisher.Publish import publish
-from Zope.Publisher.BaseRequest import BaseRequest
-from Zope.Publisher.BaseResponse import BaseResponse
+from Zope.Publisher.Browser.BrowserRequest import TestRequest
from Zope.App.ZopePublication.ZopePublication import ZopePublication
-from Zope.App.ZopePublication.ZopePublication import BrowserPublication
+from Zope.App.ZopePublication.Browser.Publication import BrowserPublication
from Zope.Configuration.name import resolve
from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
-from Zope.Publisher.DefaultPublication import DefaultPublication
+from Zope.Publisher.DefaultPublication import TestPublication
from Zope.Publisher.IPublication import IPublication
from Zope.ContextWrapper import Wrapper, getobject, getcontext
import ZODB
@@ -41,18 +40,19 @@
from StringIO import StringIO
def foo():
+ " "
return '<html><body>hello base fans</body></html>'
class DummyPublished:
__implements__ = IBrowserPublisher
- def browser_traverse(self, request, name):
+ def publishTraverse(self, request, name):
if name == 'bruce':
return foo
raise KeyError, name
- def browser_default(self, request):
+ def browserDefault(self, request):
return self, ['bruce']
class DummyView(DummyPublished):
@@ -96,15 +96,11 @@
def testInterfacesVerify(self):
for interface in instancesOfObjectImplements(self.klass):
- verifyClass(interface, DefaultPublication)
+ verifyClass(interface, TestPublication)
- def _createRequest(self, path, publication):
- outstream = StringIO()
- response = BaseResponse(outstream)
- instream = StringIO("")
- request = BaseRequest(response, instream, publication)
- request.setViewType( IBrowserPublisher )
- request.other['PATH_INFO'] = path
+ def _createRequest(self, path, publication, **kw):
+ request = TestRequest(PATH_INFO=path, **kw)
+ request.setPublication(publication)
return request
class ZopePublicationTests(BasePublicationTests):
@@ -122,16 +118,19 @@
def testBaseTagNoBase(self):
# XXX WRONG!
- self._testBaseTags('/somepath/view;view/', '/somepath/view;view/')
+ self._testBaseTags('/somepath/view;view/', '')
def testBaseTag1(self):
- self._testBaseTags('/somepath/view;view', '/somepath/view;view/')
+ self._testBaseTags('/somepath/view;view',
+ 'http://127.0.0.1/somepath/view;view/bruce')
def testBaseTag2(self):
- self._testBaseTags('/somepath/', '/somepath/view;view/')
+ self._testBaseTags('/somepath/',
+ 'http://127.0.0.1/somepath/view;view/bruce')
def testBaseTag3(self):
- self._testBaseTags('/somepath', '/somepath/view;view/')
+ self._testBaseTags('/somepath',
+ 'http://127.0.0.1/somepath/view;view/bruce')
@@ -172,19 +171,17 @@
connection.close()
req = self._createRequest(url, pub)
+ response = req.getResponse()
publish(req)
- self.assertEqual(req.response.getBase(), expected)
-
- def _createRequest(self, path, publication):
- outstream = StringIO()
- response = BaseResponse(outstream)
- instream = StringIO("")
- request = BaseRequest(response, instream, publication)
- request.setViewType( IBrowserPublisher )
- request.other['PATH_INFO'] = path
- return request
+ self.assertEqual(response.getBase(), expected)
+
+
+ def _createRequest(self, path, publication, **kw):
+ request = TestRequest(PATH_INFO=path, **kw)
+ request.setPublication(publication)
+ return request
class BrowserPublicationTests(BasePublicationTests):
@@ -203,15 +200,17 @@
pass
class mydict(dict):
+ " "
__implements__ = I1
class Adapter:
+ " "
__implements__ = IBrowserPublisher
def __init__(self, context):
self.context = context
self.counter = 0
- def browser_traverse(self, request, name):
+ def publishTraverse(self, request, name):
self.counter+=1
return self.context[name]
@@ -239,7 +238,7 @@
def __init__(self, context):
self.context = context
- def browser_default(self, request):
+ def browserDefault(self, request):
return (self.context['bruce'], 'dummy')
provideView(I1, '_traverse', IBrowserPublisher, Adapter)