[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests - test_browserwidget.py:1.10 test_radiowidget.py:1.5

Steve Alexander steve@cat-box.net
Fri, 4 Apr 2003 10:39:30 -0500


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

Modified Files:
	test_browserwidget.py test_radiowidget.py 
Log Message:
The RadioWidget was not producing valid xhtml transitional.
The label had a 'for' attribute that didn't have a matching id.
I've fixed this by removing the 'for' on the label for the general case,
and including a 'for' that points to the id of the 'field' div when
you ask the widget to render a row.


=== Zope3/src/zope/app/browser/form/tests/test_browserwidget.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/browser/form/tests/test_browserwidget.py:1.9	Tue Mar 25 18:20:57 2003
+++ Zope3/src/zope/app/browser/form/tests/test_browserwidget.py	Fri Apr  4 10:39:29 2003
@@ -83,7 +83,7 @@
             'pl', 'zope',
             os.path.join(path, 'testlabeltranslation.mo'))
         translationService.addCatalog(catalog)
-        
+
         label = ' '.join(self._widget.label().strip().split())
         self.assertEqual(label, '<label for="field.foo">oofay itletay</label>')
 


=== Zope3/src/zope/app/browser/form/tests/test_radiowidget.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/form/tests/test_radiowidget.py:1.4	Thu Feb 20 09:45:44 2003
+++ Zope3/src/zope/app/browser/form/tests/test_radiowidget.py	Fri Apr  4 10:39:29 2003
@@ -69,7 +69,36 @@
         self._widget.extra = 'style="color: red"'
         self._verifyResult(self._widget.renderHidden(value), check_list)
 
+    def testLabel(self):
+        label = ' '.join(self._widget.label().strip().split())
+        self.assertEqual(label, 'Foo Title')
 
+    def testTranslatedLabel(self):
+        import zope.app.browser.form.tests
+        from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
+        from zope.i18n.globaltranslationservice import translationService
+        import os
+        path = os.path.dirname(zope.app.browser.form.tests.__file__)
+        catalog = GettextMessageCatalog(
+            'pl', 'zope',
+            os.path.join(path, 'testlabeltranslation.mo'))
+        translationService.addCatalog(catalog)
+
+        label = ' '.join(self._widget.label().strip().split())
+        self.assertEqual(label, 'oofay itletay')
+
+    def testRow(self):
+        self._widget.request.form.clear()
+        label = ''.join(self._widget.label().strip().split())
+        value = ''.join(self._widget().strip().split())
+        row = ''.join(self._widget.row().strip().split())
+        id = 'field.foo'
+        self.assertEqual(row, '<divclass="label">'
+                              '<labelfor="%s">%s</label>'
+                              '</div>'
+                              '<divclass="field"id="%s">'
+                              '%s'
+                              '</div>' % (id, label, id, value))
 
 def test_suite():
     return makeSuite(RadioWidgetTest)