[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services/tests - test_field_widget.py:1.14

Garrett Smith garrett at mojave-corp.com
Wed Aug 13 18:28:57 EDT 2003


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

Modified Files:
	test_field_widget.py 
Log Message:
Made the following changes to the widget machinery:

- Renamed IWidget getData to getInputValue

getInputValue no longer accepts an 'optional' flag. If value is missing or is invalid, getInputValue will raise an error. Calls made to this method should be in a try...except block to handle such conditions.

- Renamed IWidget haveData to hasInput

- Added method hasValidInput to IWidget and widget implementations

- Renamed IWidget setData to setRenderedValue

- Added functional tests for some of the core widgets - additional ftests are needed

- Deleted the class PossibleEmptyMeansMissing - it's no longer needed

- Added deprecation tests for changes to widgets

- Some widgets were refactored to use the new framework correctly

These changes were based on the proposal:

 http://dev.zope.org/Zope3/ComponentArchitecture/WidgetsFormsSchemas

Not all the changes in the proposal are included in this commit. Specifically, getRawData/setRawData and the refactoring of the widget error classes are the two major changes not included in this commit.

=== Zope3/src/zope/app/browser/services/tests/test_field_widget.py 1.13 => 1.14 ===
--- Zope3/src/zope/app/browser/services/tests/test_field_widget.py:1.13	Mon Jun 30 12:23:33 2003
+++ Zope3/src/zope/app/browser/services/tests/test_field_widget.py	Wed Aug 13 17:28:23 2003
@@ -29,6 +29,7 @@
     def __init__(self, context, type):
         self.context = context
         self.type = type
+        self.missing_value = None
 
     def validate(self, value):
         pass
@@ -105,21 +106,20 @@
         self.assertEqual(widget._convert(u''), None)
         self.assertEqual(widget._convert(u'/a'), u'/a')
 
-    def test_haveData(self):
+    def test_hasInput(self):
 
-        # Empty string means we don't have data
         fake = FakeComponentPath(None, I1)
-        self.request.form['field.X'] = ''
+        self.assert_('field.X' not in self.request.form)
         widget = self.createWidget(fake, self.request)
-        self.failIf(widget.haveData())
+        self.failIf(widget.hasInput())
 
         self.request.form['field.X'] = '/foo'
         widget = self.createWidget(fake, self.request)
-        self.failUnless(widget.haveData())
+        self.failUnless(widget.hasInput())
 
-        self.request.form['field.X'] = None
+        del self.request.form['field.X']
         widget = self.createWidget(fake, self.request)
-        self.failIf(widget.haveData())
+        self.failIf(widget.hasInput())
 
 
 def test_suite():




More information about the Zope3-Checkins mailing list