[Zope3-checkins] CVS: Zope3/src/zope/app/form/browser/tests - test_browserwidget.py:1.5 test_checkboxwidget.py:1.3 test_datetimewidget.py:1.3 test_datewidget.py:1.3 test_filewidget.py:1.3 test_floatwidget.py:1.3 test_intwidget.py:1.3 test_itemswidget.py:1.3 test_multicheckboxwidget.py:1.6 test_objectwidget.py:1.4 test_passwordwidget.py:1.3 test_radiowidget.py:1.5 test_textareawidget.py:1.3 test_textwidget.py:1.3

Garrett Smith garrett at mojave-corp.com
Tue May 11 07:18:07 EDT 2004


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

Modified Files:
	test_browserwidget.py test_checkboxwidget.py 
	test_datetimewidget.py test_datewidget.py test_filewidget.py 
	test_floatwidget.py test_intwidget.py test_itemswidget.py 
	test_multicheckboxwidget.py test_objectwidget.py 
	test_passwordwidget.py test_radiowidget.py 
	test_textareawidget.py test_textwidget.py 
Log Message:
Updates of tests per browser widget framework refactor.


=== Zope3/src/zope/app/form/browser/tests/test_browserwidget.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/form/browser/tests/test_browserwidget.py:1.4	Fri May  7 15:43:26 2004
+++ Zope3/src/zope/app/form/browser/tests/test_browserwidget.py	Tue May 11 07:17:35 2004
@@ -20,7 +20,7 @@
 from zope.interface import Interface, implements
 
 from zope.app.tests import ztapi
-from zope.app.form.browser.widget import BrowserWidget
+from zope.app.form.browser.widget import SimpleInputWidget
 from zope.app.form.interfaces import ConversionError
 from zope.app.form.interfaces import WidgetInputError, MissingInputError
 from zope.app.tests.placelesssetup import PlacelessSetup
@@ -35,34 +35,43 @@
 class BrowserWidgetTest(PlacelessSetup,
                         support.VerifyResults,
                         unittest.TestCase):
+                            
     _FieldFactory = Text
-    _WidgetFactory = BrowserWidget
-
+    _WidgetFactory = None
+    
     def setUpContent(self, desc=u'', title=u'Foo Title'):
+        assert self._FieldFactory is not None
         class ITestContent(Interface):
             foo = self._FieldFactory(
-                    title=title,
-                    description=desc,
-                    )
+	            title=title,
+	            description=desc)
         class TestObject:
             implements(ITestContent)
-
         self.content = TestObject()
         field = ITestContent['foo']
         field = field.bind(self.content)
         request = TestRequest(HTTP_ACCEPT_LANGUAGE='pl')
         request.form['field.foo'] = u'Foo Value'
+        assert self._WidgetFactory is not None
         self._widget = self._WidgetFactory(field, request)
-
+    
     def setUp(self):
         super(BrowserWidgetTest, self).setUp()
         self.setUpContent()
 
+
+class SimpleInputWidgetTest(BrowserWidgetTest):
+    
+    _WidgetFactory = SimpleInputWidget
+
     def test_required(self):
+        # widget required defaults to its context required
+        self.assert_(self._widget.required)
+        self.assert_(self._widget.context.required)
+        # changing widget context required has no effect on widget required
         self._widget.context.required = False
-        self.failIf(self._widget.required)
-        self._widget.context.required = True
-        self.failUnless(self._widget.required)
+        self.assert_(self._widget.required)
+        self.assert_(not self._widget.context.required)
 
     def test_hasInput(self):
         self.failUnless(self._widget.hasInput())
@@ -105,9 +114,9 @@
         self.assertEqual(self._widget.label, 'oofay itletay')
 
 
-class TestWidget(BrowserWidget):
+class TestWidget(SimpleInputWidget):
 
-    def _convert(self, v):
+    def _toFieldValue(self, v):
         if v == u'barf!':
             raise ConversionError('ralph')
         return v or None
@@ -116,25 +125,25 @@
 
     _WidgetFactory = TestWidget
 
-    def test_showData(self):
+    def test_getFormValue(self):
 
-        class W(BrowserWidget):
-            def _convert(self, v):
+        class W(SimpleInputWidget):
+            def _toFieldValue(self, v):
                 return u'X' + (v or '')
 
-            def _unconvert(self, v):
+            def _toFormValue(self, v):
                 return v and v[1:] or ''
 
         field = Text(__name__ = 'foo', title = u"Foo Title")
         request = TestRequest()
 
         w = W(field, request)
-        self.assertEqual(w._showData(), '')
+        self.assertEqual(w._getFormValue(), '')
         request.form['field.foo'] = 'val'
-        self.assertEqual(w._showData(), 'val')
+        self.assertEqual(w._getFormValue(), 'val')
 
         w.setRenderedValue('Xfoo')
-        self.assertEqual(w._showData(), 'foo')
+        self.assertEqual(w._getFormValue(), 'foo')
 
     def test_hasValidInput(self):
         self.assertEqual(self._widget.getInputValue(), u'Foo Value')
@@ -183,11 +192,11 @@
         self._widget.request.form['field.foo'] = u''
         self.failUnless(self._widget.hasInput())
 
-    def test_showData_w_default(self):
+    def test_getFormValue_w_default(self):
         field = Text(__name__ = 'foo', title = u"Foo Title", default=u"def")
         request = TestRequest()
         widget = self._WidgetFactory(field, request)
-        self.assertEqual(widget._showData(), u'def')
+        self.assertEqual(widget._getFormValue(), u'def')
 
 
 def test_suite():


=== Zope3/src/zope/app/form/browser/tests/test_checkboxwidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_checkboxwidget.py:1.2	Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_checkboxwidget.py	Tue May 11 07:17:35 2004
@@ -22,10 +22,10 @@
 from zope.schema import Bool
 from zope.interface.verify import verifyClass
 
-from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
 
 
-class CheckBoxWidgetTest(BrowserWidgetTest):
+class CheckBoxWidgetTest(SimpleInputWidgetTest):
     """Documents and tests thec checkbox widget.
         
         >>> verifyClass(IInputWidget, CheckBoxWidget)


=== Zope3/src/zope/app/form/browser/tests/test_datetimewidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_datetimewidget.py:1.2	Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_datetimewidget.py	Tue May 11 07:17:35 2004
@@ -16,7 +16,7 @@
 """
 import unittest, doctest
 from zope.app.datetimeutils import parseDatetimetz
-from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
 from zope.app.form.interfaces import IInputWidget
 from zope.app.form.browser import DatetimeWidget
 from zope.app.form.interfaces import ConversionError, WidgetInputError
@@ -25,7 +25,7 @@
 from zope.schema import Datetime
 
 
-class DatetimeWidgetTest(BrowserWidgetTest):
+class DatetimeWidgetTest(SimpleInputWidgetTest):
     """Documents and tests the datetime widget.
         
         >>> verifyClass(IInputWidget, DatetimeWidget)


=== Zope3/src/zope/app/form/browser/tests/test_datewidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_datewidget.py:1.2	Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_datewidget.py	Tue May 11 07:17:35 2004
@@ -16,14 +16,14 @@
 """
 import unittest, doctest
 from zope.app.datetimeutils import parseDatetimetz
-from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
 from zope.app.form.interfaces import IInputWidget
 from zope.app.form.browser import DateWidget
 from zope.app.form.interfaces import ConversionError, WidgetInputError
 from zope.schema import Date
 from zope.interface.verify import verifyClass
 
-class DateWidgetTest(BrowserWidgetTest):
+class DateWidgetTest(SimpleInputWidgetTest):
     """Documents and tests the date widget.
 
         >>> verifyClass(IInputWidget, DateWidget)


=== Zope3/src/zope/app/form/browser/tests/test_filewidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_filewidget.py:1.2	Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_filewidget.py	Tue May 11 07:17:35 2004
@@ -20,11 +20,11 @@
 from zope.app.form.interfaces import IInputWidget
 from zope.app.form.browser import FileWidget
 
-from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
 
 from zope.interface.verify import verifyClass
 
-class FileWidgetTest(BrowserWidgetTest):
+class FileWidgetTest(SimpleInputWidgetTest):
     """Documents and tests the file widget.
     
         >>> verifyClass(IInputWidget, FileWidget)
@@ -34,8 +34,7 @@
     _WidgetFactory = FileWidget
 
     def setUp(self):
-        BrowserWidgetTest.setUp(self)
-
+        super(FileWidgetTest, self).setUp()
         file = StringIO('Foo Value')
         file.filename = 'test.txt'
         self._widget.request.form['field.foo'] = file


=== Zope3/src/zope/app/form/browser/tests/test_floatwidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_floatwidget.py:1.2	Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_floatwidget.py	Tue May 11 07:17:35 2004
@@ -15,7 +15,7 @@
 $Id$
 """
 import unittest, doctest
-from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
 from zope.app.form.interfaces import IInputWidget
 from zope.app.form.browser import FloatWidget
 from zope.app.form.interfaces import ConversionError, WidgetInputError
@@ -24,7 +24,7 @@
 from zope.schema import Float
 
 
-class FloatWidgetTest(BrowserWidgetTest):
+class FloatWidgetTest(SimpleInputWidgetTest):
     """Documents and tests the float widget.
         
         >>> verifyClass(IInputWidget, FloatWidget)


=== Zope3/src/zope/app/form/browser/tests/test_intwidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_intwidget.py:1.2	Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_intwidget.py	Tue May 11 07:17:36 2004
@@ -16,7 +16,7 @@
 """
 import unittest, doctest
 from unittest import main, makeSuite
-from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
 from zope.app.form.interfaces import IInputWidget
 from zope.app.form.browser import IntWidget
 from zope.app.form.interfaces import ConversionError, WidgetInputError
@@ -25,7 +25,7 @@
 from zope.schema import Int
 
 
-class IntWidgetTest(BrowserWidgetTest):
+class IntWidgetTest(SimpleInputWidgetTest):
     """Documents and tests the int widget.
         
         >>> verifyClass(IInputWidget, IntWidget)


=== Zope3/src/zope/app/form/browser/tests/test_itemswidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_itemswidget.py:1.2	Thu May  6 12:13:41 2004
+++ Zope3/src/zope/app/form/browser/tests/test_itemswidget.py	Tue May 11 07:17:36 2004
@@ -192,7 +192,7 @@
     def test_error(self):
         widget = self._makeWidget(form={'field.choice': 'ten'})
         widget.setPrefix('field.')
-        widget._showData()
+        widget._getFormValue()
         self.assert_(isinstance(widget._error, WidgetInputError))
 
 class SelectWidgetTest(ItemsEditWidgetBaseTest):
@@ -378,7 +378,7 @@
     def test_error(self):
         widget = self._makeWidget(form={'field.numbers': ['ten']})
         widget.setPrefix('field.')
-        widget._showData()
+        widget._getFormValue()
         self.assert_(isinstance(widget._error, WidgetInputError))
 
 


=== Zope3/src/zope/app/form/browser/tests/test_multicheckboxwidget.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/form/browser/tests/test_multicheckboxwidget.py:1.5	Fri May  7 15:43:26 2004
+++ Zope3/src/zope/app/form/browser/tests/test_multicheckboxwidget.py	Tue May 11 07:17:36 2004
@@ -21,10 +21,10 @@
 
 from zope.app.form.interfaces import IInputWidget
 from zope.app.form.browser import MultiCheckBoxWidget
-from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
 from zope.interface.verify import verifyClass
 
-class MultiCheckBoxWidgetTest(BrowserWidgetTest):
+class MultiCheckBoxWidgetTest(SimpleInputWidgetTest):
     """Documents and tests the multi checkbox widget.
         
         >>> verifyClass(IInputWidget, MultiCheckBoxWidget)


=== Zope3/src/zope/app/form/browser/tests/test_objectwidget.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/form/browser/tests/test_objectwidget.py:1.3	Fri May  7 15:41:33 2004
+++ Zope3/src/zope/app/form/browser/tests/test_objectwidget.py	Tue May 11 07:17:36 2004
@@ -63,17 +63,9 @@
         self.request = TestRequest(HTTP_ACCEPT_LANGUAGE='pl')
         self.request.form['field.foo'] = u'Foo Value'
         self._widget = self._WidgetFactory(self.field, self.request)
-        
-    def test_hasInput(self):
-        # doesn't work with subfields
-        pass
-
-    def testRender(self):
-        # doesn't work with subfields
-        pass
 
     def setUp(self):
-        BrowserWidgetTest.setUp(self)
+        super(ObjectWidgetTest, self).setUp()
         self.field = Object(ITestContact, __name__=u'foo')
         ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget)
 


=== Zope3/src/zope/app/form/browser/tests/test_passwordwidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_passwordwidget.py:1.2	Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_passwordwidget.py	Tue May 11 07:17:36 2004
@@ -18,10 +18,10 @@
 
 from zope.app.form.interfaces import IInputWidget
 from zope.app.form.browser import PasswordWidget
-from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
 from zope.interface.verify import verifyClass
 
-class PasswordWidgetTest(BrowserWidgetTest):
+class PasswordWidgetTest(SimpleInputWidgetTest):
     """Documents and tests the password widget.
 
         >>> verifyClass(IInputWidget, PasswordWidget)


=== Zope3/src/zope/app/form/browser/tests/test_radiowidget.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/form/browser/tests/test_radiowidget.py:1.4	Fri May  7 15:43:26 2004
+++ Zope3/src/zope/app/form/browser/tests/test_radiowidget.py	Tue May 11 07:17:36 2004
@@ -28,10 +28,10 @@
 from zope.app.tests import ztapi
 from zope.app.form.interfaces import IInputWidget
 from zope.app.form.browser import RadioWidget
-from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
 import zope.app.form.browser.tests
 
-class RadioWidgetTest(BrowserWidgetTest):
+class RadioWidgetTest(SimpleInputWidgetTest):
     """Documents and tests the radio widget.
 
         >>> verifyClass(IInputWidget, RadioWidget)


=== Zope3/src/zope/app/form/browser/tests/test_textareawidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_textareawidget.py:1.2	Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_textareawidget.py	Tue May 11 07:17:36 2004
@@ -18,10 +18,10 @@
 
 from zope.app.form.interfaces import IInputWidget
 from zope.app.form.browser import TextAreaWidget
-from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
 from zope.interface.verify import verifyClass
 
-class TextAreaWidgetTest(BrowserWidgetTest):
+class TextAreaWidgetTest(SimpleInputWidgetTest):
     """Documents and tests the text area widget.
 
         >>> verifyClass(IInputWidget, TextAreaWidget)


=== Zope3/src/zope/app/form/browser/tests/test_textwidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_textwidget.py:1.2	Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_textwidget.py	Tue May 11 07:17:36 2004
@@ -21,9 +21,9 @@
 
 from zope.app.form.interfaces import IInputWidget
 from zope.app.form.browser import TextWidget
-from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
 
-class TextWidgetTest(BrowserWidgetTest):
+class TextWidgetTest(SimpleInputWidgetTest):
     """Documents and tests the text widget.
 
         >>> verifyClass(IInputWidget, TextWidget)




More information about the Zope3-Checkins mailing list