[Zope3-checkins] CVS: Zope3/src/zope/app/browser/tests - test_absoluteurl.py:1.7
Albertas Agejevas
alga@codeworks.lt
Tue, 15 Apr 2003 06:57:09 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv31824/src/zope/app/browser/tests
Modified Files:
test_absoluteurl.py
Log Message:
Added virtual hosting support to the @@absolute_url view.
Attempted to reduce code duplication in AbsoluteURL and SiteAbsoluteURL.
This changes behaviour of breadcrumbs if IContainmentRoot is wrapped in
something other than a side effect. Should not matter.
=== Zope3/src/zope/app/browser/tests/test_absoluteurl.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/tests/test_absoluteurl.py:1.6 Tue Feb 11 21:17:14 2003
+++ Zope3/src/zope/app/browser/tests/test_absoluteurl.py Tue Apr 15 06:57:08 2003
@@ -41,7 +41,7 @@
class TrivialContent(object):
"""Trivial content object, used because instances of object are rocks."""
-class Test(PlacelessSetup, TestCase):
+class TestAbsoluteURL(PlacelessSetup, TestCase):
def setUp(self):
PlacelessSetup.setUp(self)
@@ -128,9 +128,51 @@
{'name': 'c', 'url': 'http://foobar.com/++skin++ZopeTop/a/b/c'},
))
+ def testVirtualHosting(self):
+ request = TestRequest()
+ request.setViewType(IBrowserPresentation)
+
+ content = ContextWrapper(TrivialContent(), Root(), name='a')
+ content = ContextWrapper(TrivialContent(), content,
+ name='.',
+ side_effect_name="++vh++abc")
+ content = ContextWrapper(TrivialContent(), content, name='b')
+ content = ContextWrapper(TrivialContent(), content, name='c')
+ view = getView(content, 'absolute_url', request)
+ self.assertEqual(str(view), 'http://foobar.com/b/c')
+
+ breadcrumbs = view.breadcrumbs()
+ self.assertEqual(breadcrumbs,
+ ({'name': '', 'url': 'http://foobar.com'},
+ {'name': 'b', 'url': 'http://foobar.com/b'},
+ {'name': 'c', 'url': 'http://foobar.com/b/c'},
+ ))
+
+ def testVirtualHostingInFront(self):
+ request = TestRequest()
+ request.setViewType(IBrowserPresentation)
+
+ root = Root()
+ content = ContextWrapper(root, root,
+ name='.',
+ side_effect_name="++vh++abc")
+ content = ContextWrapper(TrivialContent(), content, name='a')
+ content = ContextWrapper(TrivialContent(), content, name='b')
+ content = ContextWrapper(TrivialContent(), content, name='c')
+ view = getView(content, 'absolute_url', request)
+ self.assertEqual(str(view), 'http://foobar.com/a/b/c')
+
+ breadcrumbs = view.breadcrumbs()
+ self.assertEqual(breadcrumbs,
+ ({'name': '', 'url': 'http://foobar.com'},
+ {'name': 'a', 'url': 'http://foobar.com/a'},
+ {'name': 'b', 'url': 'http://foobar.com/a/b'},
+ {'name': 'c', 'url': 'http://foobar.com/a/b/c'},
+ ))
+
def test_suite():
- return makeSuite(Test)
+ return makeSuite(TestAbsoluteURL)
if __name__=='__main__':
main(defaultTest='test_suite')