[Zope3-checkins] CVS: Zope3/src/zope/app/form/tests - test_utility.py:1.7

R. David Murray bitz@bitdance.com
Mon, 27 Jan 2003 23:48:12 -0500


Update of /cvs-repository/Zope3/src/zope/app/form/tests
In directory cvs.zope.org:/tmp/cvs-serv23066/zope/app/form/tests

Modified Files:
	test_utility.py 
Log Message:
Factored out this common pattern of getting the Fields from the schema
or using all of the Fields from the schema by default into an
internal function _fieldlist.  Added some more tests to make sure
haveWidgetsData and getWidgetsData do the right thing on when 'names'
are passed in.  Also fixed the docstring on haveWidgetsData.


=== Zope3/src/zope/app/form/tests/test_utility.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/form/tests/test_utility.py:1.6	Mon Jan 27 23:06:54 2003
+++ Zope3/src/zope/app/form/tests/test_utility.py	Mon Jan 27 23:48:09 2003
@@ -360,6 +360,19 @@
                          {'title': u'ft',
                           'description': u'fd'})
 
+    def test_getWidgetsData_w_names(self):
+        c = C()
+        request = TestRequest()
+        request.form['field.title'] = u'ft'
+        request.form['field.description'] = u'fd'
+        view = BrowserView(c, request)
+        setUpWidgets(view, I, initial=kw(title=u"ttt", description=u"ddd"))
+        self.assertEqual(getWidgetsData(view, I, names=['title']),
+                         {'title': u'ft'})
+        self.assertRaises(KeyError, getWidgetsData, view, I, names=['bar'])
+        self.assertRaises(AttributeError, getWidgetsData, view, I,
+                          names=['foo'])
+
     def test_haveWidgetsData(self):
         c = C()
         request = TestRequest()
@@ -369,6 +382,20 @@
 
         request.form['field.description'] = u'fd'
         self.failUnless(haveWidgetsData(view, I))
+
+    def test_haveWidgetsData_w_names(self):
+        c = C()
+        request = TestRequest()
+        view = BrowserView(c, request)
+        setUpWidgets(view, I, initial=kw(title=u"ttt", description=u"ddd"))
+        self.failIf(haveWidgetsData(view, I))
+
+        request.form['field.description'] = u'fd'
+        self.failUnless(haveWidgetsData(view, I))
+        self.failIf(haveWidgetsData(view, I, names=['title']))
+        self.assertRaises(KeyError, haveWidgetsData, view, I, names=['bar'])
+        self.assertRaises(AttributeError, haveWidgetsData, view, I,
+                          names=['foo'])
 
     def test_getWidgetsData_w_default(self):
         c = C()