Commit a6fe70ad authored by Evan Simpson's avatar Evan Simpson

Fix VHM tests and make them pass

parent 5493778f
......@@ -12,8 +12,8 @@
##############################################################################
__doc__='''Application support
$Id: Application.py,v 1.197 2003/12/10 17:52:46 evan Exp $'''
__version__='$Revision: 1.197 $'[11:-2]
$Id: Application.py,v 1.198 2003/12/11 19:50:27 evan Exp $'''
__version__='$Revision: 1.198 $'[11:-2]
import Globals,Folder,os,sys,App.Product, App.ProductRegistry, misc_
import time, traceback, os, Products
......@@ -148,7 +148,7 @@ class Application(Globals.ApplicationDefaultPermissions,
def absolute_url_path(self):
'''The absolute URL path of the root object is BASEPATH1 or "/".'''
try:
return self.REQUEST['BASEPATH1']
return self.REQUEST['BASEPATH1'] or '/'
except (AttributeError, KeyError):
return '/'
......
......@@ -7,7 +7,7 @@ Also see http://zope.org/Collectors/Zope/809
Note: Tests require Zope >= 2.7
$Id: testVirtualHostMonster.py,v 1.2 2003/12/10 17:52:47 evan Exp $
$Id: testVirtualHostMonster.py,v 1.3 2003/12/11 19:50:27 evan Exp $
"""
from Testing.makerequest import makerequest
......@@ -73,17 +73,21 @@ def gen_cases():
yield '/'.join(vparts), vr, _vh, p, ubase
for i, (vaddr, vr, _vh, p, ubase) in enumerate(gen_cases()):
def test(self):
def test(self, vaddr=vaddr, vr=vr, _vh=_vh, p=p, ubase=ubase):
ob = self.traverse('%s/%s/' % (vaddr, p))
vhp = '/' + '/'.join([x for x in _vh, p if x])
self.assertEqual(ob.absolute_url(), ubase + vhp)
self.assertEqual(ob.absolute_url_path(), vhp)
sl_vh = (_vh and ('/' + _vh))
aup = sl_vh + (p and ('/' + p))
self.assertEqual(ob.absolute_url_path(), aup)
self.assertEqual(self.app.REQUEST['BASEPATH1'] + '/' + p, aup)
self.assertEqual(ob.absolute_url(), ubase + aup)
self.assertEqual(ob.absolute_url(relative=1), p)
self.assertEqual(ob.virtual_url_path(), p)
self.assertEqual(ob.getPhysicalPath(), ('', 'folder', 'doc'))
app = ob.aq_parent.aq_parent
self.assertEqual(app.absolute_url(), ubase + '/' + _vh)
# The absolute URL doesn't end with a slash
self.assertEqual(app.absolute_url(), ubase + sl_vh)
# The absolute URL path always begins with a slash
self.assertEqual(app.absolute_url_path(), '/' + _vh)
self.assertEqual(app.absolute_url(relative=1), '')
self.assertEqual(app.virtual_url_path(), '')
......
......@@ -11,7 +11,7 @@
#
##############################################################################
__version__='$Revision: 1.94 $'[11:-2]
__version__='$Revision: 1.95 $'[11:-2]
import re, sys, os, urllib, time, random, cgi, codecs
from types import StringType, UnicodeType
......@@ -1149,7 +1149,7 @@ class HTTPRequest(BaseRequest):
v.insert(0, '')
else:
v.insert(0, other['SERVER_URL'])
URL = '/'.join(v) or '/'
URL = '/'.join(v)
if other.has_key('PUBLISHED'):
# Don't cache URLs until publishing traversal is done.
other[key] = URL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment