[Zope-Checkins] CVS: Zope/lib/python/Products/SiteAccess/tests -
__init__.py:1.1.2.1 testVirtualHostMonster.py:1.1.2.1
Stefan H. Holek
cvs-admin at zope.org
Mon Dec 8 11:34:36 EST 2003
Update of /cvs-repository/Zope/lib/python/Products/SiteAccess/tests
In directory cvs.zope.org:/tmp/cvs-serv14549/tests
Added Files:
Tag: Zope-2_7-branch
__init__.py testVirtualHostMonster.py
Log Message:
Virtual Host Monster regression tests.
These tests mainly verify that OFS.Traversable.absolute_url()
works correctly in a VHM environment.
Also see http://zope.org/Collectors/Zope/809
Note: Tests require Zope >= 2.7
=== Added File Zope/lib/python/Products/SiteAccess/tests/__init__.py ===
# SiteAccess test package
=== Added File Zope/lib/python/Products/SiteAccess/tests/testVirtualHostMonster.py ===
"""Virtual Host Monster regression tests.
These tests mainly verify that OFS.Traversable.absolute_url()
works correctly in a VHM environment.
Also see http://zope.org/Collectors/Zope/809
Note: Tests require Zope >= 2.7
$Id: testVirtualHostMonster.py,v 1.1.2.1 2003/12/08 16:34:35 shh Exp $
"""
from Testing.makerequest import makerequest
import Zope
Zope.startup()
import unittest
class VHMRegressions(unittest.TestCase):
def setUp(self):
get_transaction().begin()
self.app = makerequest(Zope.app())
try:
self.app.manage_addProduct['SiteAccess'].manage_addVirtualHostMonster('VHM')
self.app.manage_addFolder('folder')
self.app.folder.manage_addDTMLMethod('doc', '')
self.app.REQUEST.set('PARENTS', [self.app])
self.traverse = self.app.REQUEST.traverse
except:
self.tearDown()
raise
def tearDown(self):
get_transaction().abort()
self.app._p_jar.close()
def testAbsoluteUrl(self):
m = self.app.folder.doc.absolute_url
self.assertEqual(m(), 'http://foo/folder/doc')
def testRelativeUrl(self):
m = self.app.folder.doc.absolute_url
self.assertEqual(m(relative=1), 'folder/doc')
def testPhysicalPath(self):
m = self.app.folder.doc.getPhysicalPath
self.assertEqual(m(), ('', 'folder', 'doc'))
def testTraverseAbsoluteUrl(self):
m = self.traverse('/folder/doc/absolute_url')
self.assertEqual(m(), 'http://foo/folder/doc')
def testTraverseRelativeUrl(self):
m = self.traverse('/folder/doc/absolute_url')
self.assertEqual(m(relative=1), 'folder/doc')
def testTraversePhysicalPath(self):
m = self.traverse('/folder/doc/getPhysicalPath')
self.assertEqual(m(), ('', 'folder', 'doc'))
def testTraverseAbsoluteUrlVH_1(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/folder/doc/absolute_url')
self.assertEqual(m(), 'http://example.com/folder/doc')
def testTraverseRelativeUrlVH_1(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/folder/doc/absolute_url')
self.assertEqual(m(relative=1), 'folder/doc')
def testTraversePhysicalPathVH_1(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/folder/doc/getPhysicalPath')
self.assertEqual(m(), ('', 'folder', 'doc'))
def testTraverseAbsoluteUrlVH_2(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/folder/VirtualHostRoot/doc/absolute_url')
self.assertEqual(m(), 'http://example.com/doc')
def testTraverseRelativeUrlVH_2(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/folder/VirtualHostRoot/doc/absolute_url')
self.assertEqual(m(relative=1), 'doc')
def testTraversePhysicalPathVH_2(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/folder/VirtualHostRoot/doc/getPhysicalPath')
self.assertEqual(m(), ('', 'folder', 'doc'))
def testTraverseAbsoluteUrlVH_3(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/folder/VirtualHostRoot/_vh_foo/doc/absolute_url')
self.assertEqual(m(), 'http://example.com/foo/doc')
def testTraverseRelativeUrlVH_3(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/folder/VirtualHostRoot/_vh_foo/doc/absolute_url')
self.assertEqual(m(relative=1), 'foo/doc')
def testTraversePhysicalPathVH_3(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/folder/VirtualHostRoot/_vh_foo/doc/getPhysicalPath')
self.assertEqual(m(), ('', 'folder', 'doc'))
def testTraverseAbsoluteUrlVH_4(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/VirtualHostRoot/_vh_foo/folder/doc/absolute_url')
self.assertEqual(m(), 'http://example.com/foo/folder/doc')
def testTraverseRelativeUrlVH_4(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/VirtualHostRoot/_vh_foo/folder/doc/absolute_url')
self.assertEqual(m(relative=1), 'foo/folder/doc')
def testTraversePhysicalPathVH_4(self):
m = self.traverse('/VirtualHostBase/http/example.com:80/VirtualHostRoot/_vh_foo/folder/doc/getPhysicalPath')
self.assertEqual(m(), ('', 'folder', 'doc'))
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(VHMRegressions))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
More information about the Zope-Checkins
mailing list