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

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


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

Modified Files:
	test_utility.py 
Log Message:
setUpEditWidgets had the same issue as setUpWdigets, naturally. 
Fixed the same way.


=== Zope3/src/zope/app/form/tests/test_utility.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/form/tests/test_utility.py:1.5	Mon Jan 27 22:40:10 2003
+++ Zope3/src/zope/app/form/tests/test_utility.py	Mon Jan 27 23:06:54 2003
@@ -181,7 +181,7 @@
         self.assertEqual(view.title(), u'title: ')
         self.assertEqual(view.description(), u'description: ')
 
-    def test_setupWidgets_only_some_fields(self):
+    def test_setupWidgets_via_names(self):
         c = C()
         request = TestRequest()
         view = BrowserView(c, request)
@@ -257,6 +257,27 @@
         setUpEditWidgets(view, I)
         self.assertEqual(view.title(), u'title: ft')
         self.assertEqual(view.description(), u'description: fd')
+
+    def test_setupEditWidgets_via_names(self):
+        c = C()
+        c.title = u'ct'
+        request = TestRequest()
+        request.form['field.title'] = u'ft'
+        view = BrowserView(c, request)
+        setUpEditWidgets(view, I, names=['title'])
+        self.assertEqual(view.title(), u'title: ft')
+        self.failIf(hasattr(view, 'description'))
+
+    def test_setupWidgets_bad_field_name(self):
+        c = C()
+        request = TestRequest()
+        view = BrowserView(c, request)
+        self.assertRaises(KeyError, setUpEditWidgets, view, I, names=['bar'])
+        #This AttributeError occurs when setUpEditWidget tries to call
+        #bind on the non-Field (Method) object.  The point is that
+        #that *some* error should occur, not necessarily this specific one.
+        self.assertRaises(AttributeError, setUpEditWidgets, view,
+                          I, names=['foo'])
 
     def test_setupEditWidgets_w_form_data_force(self):
         c = C()