[Zope3-checkins] CVS: Zope3/src/zope/app/browser/component/tests - test_interfacewidget.py:1.5
Steve Alexander
steve@cat-box.net
Mon, 6 Jan 2003 13:40:02 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/component/tests
In directory cvs.zope.org:/tmp/cvs-serv30732/src/zope/app/browser/component/tests
Modified Files:
test_interfacewidget.py
Log Message:
Gave the interface and interfaces fields a basetype that can be None.
Made widgets display the interface name "Anything" for the catch-all
interface None.
Updated adapter and view configuration schemas to use None as the
basetype for for_interface
=== Zope3/src/zope/app/browser/component/tests/test_interfacewidget.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/component/tests/test_interfacewidget.py:1.4 Mon Jan 6 09:49:09 2003
+++ Zope3/src/zope/app/browser/component/tests/test_interfacewidget.py Mon Jan 6 13:39:29 2003
@@ -63,6 +63,147 @@
class TestMultiInterfaceWidget(BaseInterfaceWidgetTest):
+ def testMultiInterfaceWidgetNone(self):
+ request = self.request
+ field = InterfacesField(__name__='TestName',
+ title=u'This is a test',
+ basetype=None)
+ widget = MultiInterfaceWidget(field, request)
+
+ self.assertEqual(widget.getData(), ())
+
+ out = (
+ 'Use refresh to enter more interfaces'
+ '<br>'
+
+ '<input type="text" name="field.TestName.search.i0" value="">'
+
+ '<select name="field.TestName.i0">'
+
+ '<option value="">---select interface---</option>'
+ '<option value="'
+ 'None'
+ '">'
+ 'Anything'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '</option>'
+
+ '</select>'
+
+ '<br>'
+
+ '<input type="text" name="field.TestName.search.i1" value="">'
+
+ '<select name="field.TestName.i1">'
+
+ '<option value="">---select interface---</option>'
+ '<option value="'
+ 'None'
+ '">'
+ 'Anything'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '</option>'
+
+ '</select>'
+ )
+ self.assertEqual(widget(), out)
+
+ request.form["field.TestName.i1"] = 'None'
+ self.assertEqual(widget.getData(), (None,))
+
+ out = (
+ 'Use refresh to enter more interfaces'
+ '<br>'
+
+ '<input type="text" name="field.TestName.search.i0" value="">'
+
+ '<select name="field.TestName.i0">'
+
+ '<option value="">---select interface---</option>'
+ '<option value="'
+ 'None'
+ '">'
+ 'Anything'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '</option>'
+
+ '</select>'
+
+ '<br>'
+
+ '<input type="text" name="field.TestName.search.i1" value="">'
+
+ '<select name="field.TestName.i1">'
+
+ '<option value="">---select interface---</option>'
+ '<option value="'
+ 'None'
+ '" selected>'
+ 'Anything'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '</option>'
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '</option>'
+
+ '</select>'
+ )
+ self.assertEqual(widget(), out)
+
+
def testMultiInterfaceWidget(self):
request = self.request
field = InterfacesField(__name__='TestName',
@@ -236,14 +377,97 @@
)
-
class TestInterfaceWidget(BaseInterfaceWidgetTest):
+ def testInterfaceWidgetNone(self):
+
+ request = self.request
+ field = InterfaceField(__name__='TestName',
+ title=u"This is a test",
+ basetype=None)
+
+ widget = InterfaceWidget(field, request)
+
+ self.assertEqual(widget.getData(), None)
+
+ out = (
+ '<input type="text" name="field.TestName.search" value="">'
+ '<select name="field.TestName">'
+ '<option value="">---select interface---</option>'
+
+ '<option value="'
+ 'None'
+ '">'
+ 'Anything'
+ '</option>'
+
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '</option>'
+
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '</option>'
+
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '</option>'
+
+ '</select>'
+ )
+
+ self.assertEqual(widget(), out)
+
+ request.form["field.TestName"] = (
+ 'None'
+ )
+ self.assertEqual(widget.getData(), None)
+
+ out = (
+ '<input type="text" name="field.TestName.search" value="">'
+ '<select name="field.TestName">'
+ '<option value="">---select interface---</option>'
+
+ '<option value="'
+ 'None'
+ '" selected>'
+ 'Anything'
+ '</option>'
+
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I'
+ '</option>'
+
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ '</option>'
+
+ '<option value="'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '">'
+ 'zope.app.browser.component.tests.test_interfacewidget.I3'
+ '</option>'
+
+ '</select>'
+ )
+
+ self.assertEqual(widget(), out)
+
def testInterfaceWidget(self):
request = self.request
field = InterfaceField(__name__='TestName',
- title=u"This is a test",
- required=False)
+ title=u"This is a test",
+ required=False)
widget = InterfaceWidget(field, request)
@@ -303,7 +527,7 @@
'</select>'
)
- self.assertEqual(widget.render(I), out)
+ # self.assertEqual(widget.render(I), out)
self.assertEqual(widget.getData(), None)