[Zope-Checkins] CVS: Products/SiteAccess/tests -
testVirtualHostMonster.py:1.1.2.2
Evan Simpson
evan at 4-am.com
Wed Dec 10 12:54:03 EST 2003
Update of /cvs-repository/Products/SiteAccess/tests
In directory cvs.zope.org:/tmp/cvs-serv13961/lib/python/Products/SiteAccess/tests
Modified Files:
Tag: Zope-2_7-branch
testVirtualHostMonster.py
Log Message:
Collector #809: Added and documented Traversable.py methods absolute_url_path and virtual_url_path, and reverted earlier change to absolute_url behaviour.
=== Products/SiteAccess/tests/testVirtualHostMonster.py 1.1.2.1 => 1.1.2.2 ===
--- Products/SiteAccess/tests/testVirtualHostMonster.py:1.1.2.1 Mon Dec 8 11:34:35 2003
+++ Products/SiteAccess/tests/testVirtualHostMonster.py Wed Dec 10 12:53:32 2003
@@ -31,7 +31,6 @@
self.traverse = self.app.REQUEST.traverse
except:
self.tearDown()
- raise
def tearDown(self):
get_transaction().abort()
@@ -41,73 +40,55 @@
m = self.app.folder.doc.absolute_url
self.assertEqual(m(), 'http://foo/folder/doc')
- def testRelativeUrl(self):
+ def testAbsoluteUrlPath(self):
+ m = self.app.folder.doc.absolute_url_path
+ self.assertEqual(m(), '/folder/doc')
+
+ def testVirtualUrlPath(self):
m = self.app.folder.doc.absolute_url
self.assertEqual(m(relative=1), 'folder/doc')
+ m = self.app.folder.doc.virtual_url_path
+ self.assertEqual(m(), '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 gen_cases():
+ for vbase, ubase in (
+ ('', 'http://foo'),
+ ('/VirtualHostBase/http/example.com:80', 'http://example.com'),
+ ):
+ yield vbase, '', '', 'folder/doc', ubase
+ for vr, _vh, p in (
+ ('folder', '', 'doc'),
+ ('folder', 'foo', 'doc'),
+ ('', 'foo', 'folder/doc'),
+ ):
+ vparts = [vbase, vr, 'VirtualHostRoot']
+ if not vr:
+ del vparts[1]
+ if _vh:
+ vparts.append('_vh_' + _vh)
+ yield '/'.join(vparts), vr, _vh, p, ubase
+
+for i, (vaddr, vr, _vh, p, ubase) in enumerate(gen_cases()):
+ def test(self):
+ 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)
+ 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)
+ self.assertEqual(app.absolute_url_path(), '/' + _vh)
+ self.assertEqual(app.absolute_url(relative=1), '')
+ self.assertEqual(app.virtual_url_path(), '')
- 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'))
+ setattr(VHMRegressions, 'testTraverse%s' % i, test)
def test_suite():
More information about the Zope-Checkins
mailing list