[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Forms/tests - testUtility.py:1.3

Jim Fulton jim@zope.com
Tue, 29 Oct 2002 12:12:38 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Forms/tests
In directory cvs.zope.org:/tmp/cvs-serv29399/tests

Modified Files:
	testUtility.py 
Log Message:
Added option to specify a widget prefix when setting up widgets.


=== Zope3/lib/python/Zope/App/Forms/tests/testUtility.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/Forms/tests/testUtility.py:1.2	Mon Oct 28 18:52:31 2002
+++ Zope3/lib/python/Zope/App/Forms/tests/testUtility.py	Tue Oct 29 12:12:37 2002
@@ -56,6 +56,9 @@
         self.context.validate(v)
         self._data = v
 
+    def setPrefix(self, prefix):
+        self.prefix = prefix
+
     def __call__(self):
         name = self.getName()
         if name in self.request:
@@ -137,6 +140,14 @@
         self.assertEqual(view.title(), u'title: ')
         self.assertEqual(view.description(), u'description: ')
     
+    def test_setupWidgets_w_prefix(self):
+        c = C()
+        request = TestRequest()
+        view = BrowserView(c, request)
+        setUpWidgets(view, I, prefix='spam')
+        self.assertEqual(view.title.prefix, 'spam')
+        self.assertEqual(view.description.prefix, 'spam')
+    
     def test_setupWidgets_w_initial_data_and_custom_widget(self):
         c = C()
         request = TestRequest()
@@ -157,6 +168,18 @@
         setUpEditWidgets(view, I)
         self.assertEqual(view.title(), u'title: ct')
         self.assertEqual(view.description(), u'description: cd')
+        self.assertEqual(view.title, w) 
+
+    def test_setupEditWidgets_w_custom_widget_and_prefix(self):
+        c = C()
+        c.title = u'ct'
+        c.description = u'cd'
+        request = TestRequest()
+        view = BrowserView(c, request)
+        view.title = w = W(I['title'], request) 
+        setUpEditWidgets(view, I, prefix='eggs')
+        self.assertEqual(view.title.prefix, 'eggs')
+        self.assertEqual(view.description.prefix, 'eggs')
         self.assertEqual(view.title, w) 
 
     def test_setupEditWidgets_w_other_data(self):