[Zope3-checkins] CVS: Zope3/src/zope/app/browser/component/tests - test_interfacewidget.py:1.15
Steve Alexander
steve@cat-box.net
Fri, 17 Jan 2003 11:31:36 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/component/tests
In directory cvs.zope.org:/tmp/cvs-serv15686/src/zope/app/browser/component/tests
Modified Files:
test_interfacewidget.py
Log Message:
Fixed bugs todo with empty form fields. Added new test case.
=== Zope3/src/zope/app/browser/component/tests/test_interfacewidget.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/browser/component/tests/test_interfacewidget.py:1.14 Thu Jan 16 14:50:27 2003
+++ Zope3/src/zope/app/browser/component/tests/test_interfacewidget.py Fri Jan 17 11:31:33 2003
@@ -332,12 +332,12 @@
basetype=None)
widget = InterfaceWidget(field, request)
-
+
out = (
'<input type="hidden" name="field.TestName" value="None" />'
)
self.assertEqual(widget.hidden(), out)
-
+
request.form["field.TestName"] = (
'None'
)
@@ -346,7 +346,7 @@
'<input type="hidden" name="field.TestName" value="None" />'
)
self.assertEqual(widget.hidden(), out)
-
+
class TestMultiInterfaceWidget(BaseInterfaceWidgetTest):
def testMultiInterfaceWidget(self):
@@ -533,7 +533,7 @@
title=u'This is a test',
basetype=None)
widget = MultiInterfaceWidget(field, request)
-
+
self.assertEqual(widget.getData(), ())
self.failIf(widget.haveData())
@@ -670,7 +670,7 @@
self.assertEqual(widget(), out)
# test that None / Anything disappears when there is a search string
-
+
request.form["field.TestName.search.i1"] = 'two'
out = (
@@ -732,7 +732,7 @@
request.form["field.TestName.i0"] = ('bad interface name')
self.assertRaises(ConversionError, widget.getData)
-
+
def testHidden(self):
request = self.request
field = InterfacesField(__name__='TestName',
@@ -740,9 +740,9 @@
required=False)
widget = MultiInterfaceWidget(field, request)
-
+
self.assertEqual(widget.hidden(), '')
-
+
request.form["field.TestName.i0"] = (
'zope.app.browser.component.tests.test_interfacewidget.I2'
)
@@ -772,9 +772,9 @@
basetype=None)
widget = MultiInterfaceWidget(field, request)
-
+
self.assertEqual(widget.hidden(), '')
-
+
request.form["field.TestName.i0"] = (
'None'
)
@@ -783,7 +783,23 @@
'<input type="hidden" name="field.TestName.i0" value="None" />'
)
self.assertEqual(widget.hidden(), out)
-
+
+ def testEmptyFormData(self):
+ request = self.request
+ field = InterfacesField(__name__='TestName',
+ title=u'This is a test',
+ required=False)
+ widget = MultiInterfaceWidget(field, request)
+
+ self.assertEqual(widget.getData(), ())
+ self.failIf(widget.haveData())
+
+ request.form["field.TestName.i1"] = (
+ 'zope.app.browser.component.tests.test_interfacewidget.I2'
+ )
+ request.form["field.TestName.i0"] = ''
+ self.assertEqual(widget.getData(), (I2,))
+ self.failUnless(widget.haveData())
class TestRenderInterfaceSelect(TestCase):