[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/TraversalViews/tests - testAbsoluteURL.py:1.4

Jim Fulton jim@zope.com
Sat, 13 Jul 2002 10:19:08 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/TraversalViews/tests
In directory cvs.zope.org:/tmp/cvs-serv1111/lib/python/Zope/App/ZopePublication/TraversalViews/tests

Modified Files:
	testAbsoluteURL.py 
Log Message:
Fixed bug in context management when uri segments that produce only
side effects (e.g. ++skin++ZopeTop) are used.

Fixed up absolute url bread crumbs to not show side-effect steps in
bread crumbs, while retaining them in the breadcrumb urls.

Refactored side-effect handling slightly (changed context data names)
in absolute url and physical path code.

Added tests for side effect handling for absolute url, physical path,
and namespace handling code.


=== Zope3/lib/python/Zope/App/ZopePublication/TraversalViews/tests/testAbsoluteURL.py 1.3 => 1.4 ===
                           {'name': 'b', 'url': 'http://foobar.com/a/b'},
                           {'name': 'c', 'url': 'http://foobar.com/a/b/c'},
                           ))
+        
+    def testContextWSideEffectsInMiddle(self):
+        request = TestRequest()
+        request.setViewType(IBrowserPresentation)
+
+        content = ContextWrapper(TrivialContent(), Root(), name='a')
+        content = ContextWrapper(TrivialContent(), content,
+                                 name='.',
+                                 side_effect_name="++skin++ZopeTop")
+        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/++skin++ZopeTop/b/c')
+
+        breadcrumbs = view.breadcrumbs()
+        self.assertEqual(breadcrumbs,
+         ({'name':  '', 'url': 'http://foobar.com'},
+          {'name': 'a', 'url': 'http://foobar.com/a/++skin++ZopeTop'},
+          {'name': 'b', 'url': 'http://foobar.com/a/++skin++ZopeTop/b'},
+          {'name': 'c', 'url': 'http://foobar.com/a/++skin++ZopeTop/b/c'},
+          ))
+        
+    def testContextWSideEffectsInFront(self):
+        request = TestRequest()
+        request.setViewType(IBrowserPresentation)
+
+        root = Root()
+        content = ContextWrapper(root, root,
+                                 name='.',
+                                 side_effect_name="++skin++ZopeTop")
+        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/++skin++ZopeTop/a/b/c')
+
+        breadcrumbs = view.breadcrumbs()
+        self.assertEqual(breadcrumbs,
+         ({'name':  '', 'url': 'http://foobar.com/++skin++ZopeTop'},
+          {'name': 'a', 'url': 'http://foobar.com/++skin++ZopeTop/a'},
+          {'name': 'b', 'url': 'http://foobar.com/++skin++ZopeTop/a/b'},
+          {'name': 'c', 'url': 'http://foobar.com/++skin++ZopeTop/a/b/c'},
+          ))
                           
 
 def test_suite():