[Zope3-checkins] CVS: Zope3/src/zope/app/form/tests - test_utility.py:1.10
Jim Fulton
jim@zope.com
Fri, 7 Mar 2003 16:27:34 -0500
Update of /cvs-repository/Zope3/src/zope/app/form/tests
In directory cvs.zope.org:/tmp/cvs-serv12416/tests
Modified Files:
test_utility.py
Log Message:
Fixed a bug in getWidgetsData's (recently changed) handling of
readonly fields. getWidgetsData needs to read readonly fields unless
explictly told not to. We need to be able to collect data for readonly
fields in *add* forms.
=== Zope3/src/zope/app/form/tests/test_utility.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/form/tests/test_utility.py:1.9 Fri Feb 21 12:52:18 2003
+++ Zope3/src/zope/app/form/tests/test_utility.py Fri Mar 7 16:27:33 2003
@@ -396,6 +396,36 @@
self.assertRaises(AttributeError, getWidgetsData, view, I,
names=['foo'])
+ def test_getWidgetsData_w_readonly_fields(self):
+ class ITest(I):
+ name = Text(title=u"Title", readonly=True)
+
+ c = C()
+ request = TestRequest()
+ request.form['field.name'] = u'foo'
+ request.form['field.title'] = u'ft'
+ request.form['field.description'] = u'fd'
+ view = BrowserView(c, request)
+ setUpWidgets(view, ITest, initial=kw(title=u"ttt", description=u"ddd"))
+ self.assertEqual(getWidgetsData(view, ITest, names=['name', 'title']),
+ {'title': u'ft', 'name': 'foo'})
+
+ def test_getWidgetsData_w_readonly_fields_but_exclude_anyway(self):
+ class ITest(I):
+ name = Text(title=u"Title", readonly=True)
+
+ c = C()
+ request = TestRequest()
+ request.form['field.name'] = u'foo'
+ request.form['field.title'] = u'ft'
+ request.form['field.description'] = u'fd'
+ view = BrowserView(c, request)
+ setUpWidgets(view, ITest, initial=kw(title=u"ttt", description=u"ddd"))
+ self.assertEqual(
+ getWidgetsData(view, ITest, names=['name', 'title'],
+ exclude_readonly=True),
+ {'title': u'ft'})
+
def test_haveWidgetsData(self):
c = C()
request = TestRequest()