[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/tests - testZopePublication.py:1.1.2.14.2.1

Jim Fulton jim@zope.com
Tue, 26 Mar 2002 11:55:08 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/tests
In directory cvs.zope.org:/tmp/cvs-serv4886/Zope/App/ZopePublication/tests

Modified Files:
      Tag: Zope3-publisher-refactor-branch
	testZopePublication.py 
Log Message:
Got the BrowserPublisher to pass tests.

The remaining task (aside from writing more tests) is to get the
new server setup working.  This should also get the server tests to pass.


=== Zope3/lib/python/Zope/App/ZopePublication/tests/testZopePublication.py 1.1.2.14 => 1.1.2.14.2.1 ===
 
 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,6 +40,7 @@
 from StringIO import StringIO
 
 def foo():
+    " "
     return '<html><body>hello base fans</body></html>'
 
 class 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,9 +200,11 @@
             pass
 
         class mydict(dict):
+            " "
             __implements__ = I1
 
         class Adapter:
+            " "
             __implements__ = IBrowserPublisher
             def __init__(self, context):
                 self.context = context