[Zope3-checkins] CVS: Zope3/src/zope/publisher/tests - test_baserequest.py:1.4 test_http.py:1.15

Marius Gedminas mgedmin@codeworks.lt
Mon, 28 Apr 2003 09:14:22 -0400


Update of /cvs-repository/Zope3/src/zope/publisher/tests
In directory cvs.zope.org:/tmp/cvs-serv25303/src/zope/publisher/tests

Modified Files:
	test_baserequest.py test_http.py 
Log Message:
Virtual hosting did not work correctly in all cases (e.g. service configuration
paths did not have leading path elements truncated when they should have).
This is now fixed by adding a method getVirtualHostRoot to IVirtualHostRequest
and making AbsoluteURL views use that for identifying the virtual host root
instead of relying on special context wrappers.  Also added a functional test
to prevent regressions.



=== Zope3/src/zope/publisher/tests/test_baserequest.py 1.3 => 1.4 ===
--- Zope3/src/zope/publisher/tests/test_baserequest.py:1.3	Fri Apr 11 08:55:41 2003
+++ Zope3/src/zope/publisher/tests/test_baserequest.py	Mon Apr 28 09:14:22 2003
@@ -65,10 +65,13 @@
 
         request.setTraversalStack([])
         self.assertEqual(request.traverse(app).name, '')
+        self.assertEqual(request._last_obj_traversed, app)
         request.setTraversalStack(['ZopeCorp'])
         self.assertEqual(request.traverse(app).name, 'ZopeCorp')
+        self.assertEqual(request._last_obj_traversed, app.ZopeCorp)
         request.setTraversalStack(['Engineering', 'ZopeCorp'])
         self.assertEqual(request.traverse(app).name, 'Engineering')
+        self.assertEqual(request._last_obj_traversed, app.ZopeCorp.Engineering)
 
     def test_IPublisherRequest_processInputs(self):
         self._Test__new().processInputs()


=== Zope3/src/zope/publisher/tests/test_http.py 1.14 => 1.15 ===
--- Zope3/src/zope/publisher/tests/test_http.py:1.14	Fri Apr 25 06:36:39 2003
+++ Zope3/src/zope/publisher/tests/test_http.py	Mon Apr 28 09:14:22 2003
@@ -242,9 +242,18 @@
 
     def test_setVirtualHostRoot(self):
         req = self._createRequest()
+        self.assertEquals(req._vh_trunc, 0)
         req._traversed_names = ['x', 'y']
+        req._last_obj_traversed = object()
         req.setVirtualHostRoot()
         self.assertEquals(req._vh_trunc, 3)
+        self.assertEquals(req._vh_root, req._last_obj_traversed)
+
+    def test_getVirtualHostRoot(self):
+        req = self._createRequest()
+        self.assertEquals(req.getVirtualHostRoot(), None)
+        req._vh_root = object()
+        self.assertEquals(req.getVirtualHostRoot(), req._vh_root)
 
     def test_traverse(self):
         # setting _vh_trunc *before* traversal is a no-op
@@ -255,11 +264,13 @@
 
         # setting it during traversal matters
         req = self._createRequest()
-        def hook(self, object, req=req):
-            req._vh_trunc = 1
+        def hook(self, object, req=req, app=self.app):
+            if object is app:
+                req.setVirtualHostRoot()
         req.publication.callTraversalHooks = hook
         req.traverse(self.app)
         self.assertEquals(req._traversed_names, ['item'])
+        self.assertEquals(req._vh_root, self.app)
 
     def testInterface(self):
         from zope.publisher.interfaces.http import IHTTPCredentials