[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Publisher/Browser/tests - testDirectives.py:1.7

Jim Fulton jim@zope.com
Wed, 19 Jun 2002 17:31:57 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/Publisher/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv6230/lib/python/Zope/App/Publisher/Browser/tests

Modified Files:
	testDirectives.py 
Log Message:
implemented 
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/NamedBrowserViewsAndPages

I think

Well, the tests pass. :)



=== Zope3/lib/python/Zope/App/Publisher/Browser/tests/testDirectives.py 1.6 => 1.7 ===
         self.assertEqual(str(v()), '<html><body><p>done</p></body></html>\n')
 
-    def testPageViewsWithName(self):
+    def testNamedViewPageViewsNoDefault(self):
         self.assertEqual(queryView(ob, 'test', request),
                          None)
+        test3 = os.path.join(os.path.split(defs_path)[0], 'tests', 'test3.pt')
 
         xmlconfig(StringIO(template %
             """
-            <browser:view name="test"
+            <browser:view
+                  name="test"
                   factory="Zope.ComponentArchitecture.tests.TestViews.V1"
                   for="Zope.ComponentArchitecture.tests.TestViews.IC">
 
                 <browser:page name="index.html" attribute="index" /> 
                 <browser:page name="action.html" attribute="action" /> 
+                <browser:page name="test.html" template="%s" /> 
             </browser:view>
+            """ % test3
+            ))
+
+        view = getView(ob, 'test', request)
+        self.assertEqual(view.browserDefault(request)[1], (u'index.html', ))
+
+
+        v = view.publishTraverse(request, 'index.html')
+        self.assertEqual(v(), 'V1 here')
+        v = view.publishTraverse(request, 'action.html')
+        self.assertEqual(v(), 'done')
+        v = view.publishTraverse(request, 'test.html')
+        self.assertEqual(str(v()), '<html><body><p>done</p></body></html>\n')
+
+    def testNamedViewPageViewsWithDefault(self):
+        self.assertEqual(queryView(ob, 'test', request),
+                         None)
+        test3 = os.path.join(os.path.split(defs_path)[0], 'tests', 'test3.pt')
+
+        xmlconfig(StringIO(template %
             """
+            <browser:view
+                  name="test"
+                  factory="Zope.ComponentArchitecture.tests.TestViews.V1"
+                  for="Zope.ComponentArchitecture.tests.TestViews.IC">
+
+                <browser:defaultPage name="test.html" />
+                <browser:page name="index.html" attribute="index" /> 
+                <browser:page name="action.html" attribute="action" /> 
+                <browser:page name="test.html" template="%s" /> 
+            </browser:view>
+            """ % test3
             ))
 
-        v = getView(ob, 'index.html', request)
+        view = getView(ob, 'test', request)
+        self.assertEqual(view.browserDefault(request)[1], (u'test.html', ))
+
+
+        v = view.publishTraverse(request, 'index.html')
         self.assertEqual(v(), 'V1 here')
-        v = getView(ob, 'action.html', request)
+        v = view.publishTraverse(request, 'action.html')
         self.assertEqual(v(), 'done')
-        v = getView(ob, 'test', request)
-        self.assertEqual(v.index(), 'V1 here')
-        self.assertEqual(v.action(), 'done')
-    
+        v = view.publishTraverse(request, 'test.html')
+        self.assertEqual(str(v()), '<html><body><p>done</p></body></html>\n')
 
     def testProtectedPageViews(self):
         self.assertEqual(queryView(ob, 'test', request),