[Zope3-checkins] CVS: Zope3/src/zope/app/browser/security/tests -
test_permissionwidget.py:1.12
Garrett Smith
garrett at mojave-corp.com
Wed Aug 13 18:28:46 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/security/tests
In directory cvs.zope.org:/tmp/cvs-serv9151/src/zope/app/browser/security/tests
Modified Files:
test_permissionwidget.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/security/tests/test_permissionwidget.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/browser/security/tests/test_permissionwidget.py:1.11 Thu May 22 18:50:09 2003
+++ Zope3/src/zope/app/browser/security/tests/test_permissionwidget.py Wed Aug 13 17:28:11 2003
@@ -29,6 +29,7 @@
from zope.app.security.registries.permissionregistry import permissionRegistry
from zope.app.services.servicenames import Permissions
from zope.app.interfaces.security import IPermissionService
+from zope.app.interfaces.form import WidgetInputError
class TestPermissionWidget(PlacelessSetup, TestCase):
@@ -49,7 +50,7 @@
widget = SinglePermissionWidget(permissionField, request)
- self.assertEqual(widget.getData(), None)
+ self.assertRaises(WidgetInputError, widget.getInputValue)
out = (
'<input type="text" name="field.TestName.search" value="">'
@@ -106,17 +107,17 @@
'</select>'
)
- widget.setData(read_permission.getId())
+ widget.setRenderedValue(read_permission.getId())
self.assertEqual(widget(), out)
- self.assertEqual(widget.getData(), None)
+ self.assertRaises(WidgetInputError, widget.getInputValue)
widget = SinglePermissionWidget(permissionField, request)
request.form["field.TestName"] = (
'read'
)
- self.assertEqual(widget.getData(), read_permission.getId())
+ self.assertEqual(widget.getInputValue(), read_permission.getId())
self.assertEqual(widget(), out)
@@ -186,22 +187,22 @@
'</select>'
)
- widget.setData(CheckerPublic)
+ widget.setRenderedValue(CheckerPublic)
self.assertEqual(widget(), out)
- self.assertEqual(widget.getData(), None)
+ self.assertRaises(WidgetInputError, widget.getInputValue)
widget = SinglePermissionWidget(permissionField, request)
request.form["field.TestName"] = 'zope.Public'
- self.assertEqual(widget.getData(), CheckerPublic)
+ self.assertEqual(widget.getInputValue(), CheckerPublic)
self.assertEqual(widget(), out)
request.form["field.TestName"] = ''
- self.assertEqual(widget.getData(), None)
+ self.assertEqual(widget.getInputValue(), None)
def test_suite():
More information about the Zope3-Checkins
mailing list