[Zope3-checkins] CVS: Zope3/src/zope/app/component/tests -
test_directives.py:1.19
Jim Fulton
jim at zope.com
Wed Dec 17 10:37:20 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/component/tests
In directory cvs.zope.org:/tmp/cvs-serv24075/src/zope/app/component/tests
Modified Files:
test_directives.py
Log Message:
Added tests to make sure we could have unnamed views and resources.
=== Zope3/src/zope/app/component/tests/test_directives.py 1.18 => 1.19 ===
--- Zope3/src/zope/app/component/tests/test_directives.py:1.18 Wed Dec 17 05:06:29 2003
+++ Zope3/src/zope/app/component/tests/test_directives.py Wed Dec 17 10:37:20 2003
@@ -285,6 +285,37 @@
self.assertEqual(v.__class__,
V1)
+ def testUnnamedViewThatProvidesAnInterface(self):
+
+ ob = Ob()
+ self.assertEqual(queryView(ob, '', Request(IV), None), None)
+
+ xmlconfig(StringIO(template %
+ """
+ <view factory="zope.app.component.tests.views.V1"
+ for="zope.app.component.tests.views.IC"
+ type="zope.app.component.tests.views.IR"
+ />
+ """
+ ))
+
+ v = queryView(ob, '', Request(IR), None, providing=IV)
+ self.assertEqual(v, None)
+
+ xmlconfig(StringIO(template %
+ """
+ <view factory="zope.app.component.tests.views.V1"
+ for="zope.app.component.tests.views.IC"
+ type="zope.app.component.tests.views.IR"
+ provides="zope.app.component.tests.views.IV"
+ />
+ """
+ ))
+
+ v = queryView(ob, '', Request(IR), None, providing=IV)
+
+ self.assertEqual(v.__class__, V1)
+
def testInterfaceProtectedView(self):
xmlconfig(StringIO(template %
"""
@@ -495,6 +526,37 @@
))
v = queryResource(ob, 'test', Request(IR), None, providing=IV)
+
+ self.assertEqual(v.__class__, R1)
+
+ def testUnnamedResourceThatProvidesAnInterface(self):
+
+ ob = Ob()
+ self.assertEqual(queryResource(ob, '', Request(IV), None), None)
+
+ xmlconfig(StringIO(template %
+ """
+ <resource
+ factory="zope.app.component.tests.views.R1"
+ type="zope.app.component.tests.views.IR"
+ />
+ """
+ ))
+
+ v = queryResource(ob, '', Request(IR), None, providing=IV)
+ self.assertEqual(v, None)
+
+ xmlconfig(StringIO(template %
+ """
+ <resource
+ factory="zope.app.component.tests.views.R1"
+ type="zope.app.component.tests.views.IR"
+ provides="zope.app.component.tests.views.IV"
+ />
+ """
+ ))
+
+ v = queryResource(ob, '', Request(IR), None, providing=IV)
self.assertEqual(v.__class__, R1)
More information about the Zope3-Checkins
mailing list