[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/Browser/tests - testDirectives.py:1.1.2.2
Steve Alexander
steve@cat-box.net
Thu, 14 Feb 2002 11:37:17 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv15281/Publisher/Browser/tests
Modified Files:
Tag: Zope-3x-branch
testDirectives.py
Log Message:
Corrected bugs in defaultViewName registration. Added defaultViewName registration to Publisher/Browser.
Added test for browser:defaultView directive.
TODO: add test for defaultViewDirective in ComponentArchitecture/tests
=== Zope3/lib/python/Zope/Publisher/Browser/tests/testDirectives.py 1.1.2.1 => 1.1.2.2 ===
from Zope.Publisher.Browser.tests.TestViews import IC, V1, VZMI, R1, RZMI
from Zope.ComponentArchitecture import getView, getResource, _clear
+from Zope.ComponentArchitecture import getDefaultViewName
from cStringIO import StringIO
template = """<zopeConfigure
@@ -54,6 +55,30 @@
self.assertEqual(getView(ob, 'test', IBrowserPublisher, None
).__class__, V1)
+ def testDefaultView(self):
+
+ ob = Ob()
+ self.assertEqual(getView(ob, 'test', IBrowserPublisher, None), None)
+
+ xmlconfig(StringIO(template % (
+ """
+ <directive name="defaultView"
+ attributes="component, name, for, layer"
+ handler="Zope.Publisher.Browser.metaConfigure.defaultView"
+ namespace="http://namespaces.zope.org/browser" />
+ <browser:defaultView name="test"
+ factory="Zope.Publisher.Browser.tests.TestViews.V1"
+ for="Zope.Publisher.Browser.tests.TestViews.IC" />
+ """
+ )))
+
+ self.assertEqual(getView(ob, 'test', IBrowserPublisher, None
+ ).__class__, V1)
+ self.assertEqual(getDefaultViewName(ob, IBrowserPublisher
+ ), 'test')
+
+
+
def testSKinView(self):
ob = Ob()