[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests -
test_widget_deprecations.py:1.1 test_browserwidget.py:1.15
test_checkboxwidget.py:1.9 test_datetimewidget.py:1.2
test_datewidget.py:1.2 test_editview.py:1.13
test_filewidget.py:1.7 test_floatwidget.py:1.2
test_intwidget.py:1.2 test_listwidget.py:1.8
test_multicheckboxwidget.py:1.8 test_multilistwidget.py:1.8
test_objectwidget.py:1.4 test_passwordwidget.py:1.8
test_radiowidget.py:1.9 test_sequencewidget.py:1.4
test_setprefix.py:1.6 test_textareawidget.py:1.8
test_textwidget.py:1.7 test_vocabularywidget.py:1.24
Garrett Smith
garrett at mojave-corp.com
Wed Aug 13 18:29:19 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv9151/src/zope/app/browser/form/tests
Modified Files:
test_browserwidget.py test_checkboxwidget.py
test_datetimewidget.py test_datewidget.py test_editview.py
test_filewidget.py test_floatwidget.py test_intwidget.py
test_listwidget.py test_multicheckboxwidget.py
test_multilistwidget.py test_objectwidget.py
test_passwordwidget.py test_radiowidget.py
test_sequencewidget.py test_setprefix.py
test_textareawidget.py test_textwidget.py
test_vocabularywidget.py
Added Files:
test_widget_deprecations.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.
=== Added File Zope3/src/zope/app/browser/form/tests/test_widget_deprecations.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: test_widget_deprecations.py,v 1.1 2003/08/13 21:28:04 garrett Exp $
"""
import unittest
import random
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.app.browser.form.widget import BrowserWidget
from zope.app.form import widget
from zope.app.browser.form import widget as browserwidget
from zope.publisher.browser import TestRequest
from zope.schema import Text
class OldWidget(BrowserWidget):
"""Simulates a typical browser widget before the renaming of:
getData -> getInputValue
setData -> setRenderedValue
haveData -> hasInput
"""
def __init__(self, context, request):
super(OldWidget, self).__init__(context, request)
self._data = random.random() > 0.5 and u'foo' or None
def haveData(self):
return self._data is None
def getData(self):
return self._data
warnings = []
def warn(*args, **wk):
warnings.append(args[1]) # append the exception class
class TestOldWidget(PlacelessSetup, unittest.TestCase):
def setUp(self):
PlacelessSetup.setUp(self)
self._widget = OldWidget(Text(__name__='test'), TestRequest())
widget.warn = warn
browserwidget.warn = warn
global warnings
warnings = []
def test_haveInput(self):
self.assertEqual(self._widget.haveData(), self._widget.hasInput())
def test_getData(self):
self.assertEqual(self._widget.getData(), self._widget.getInputValue())
def test_setData(self):
self.assertEqual(len(warnings), 0)
self._widget.setData(u'bar')
self.assertEqual(self._widget.getInputValue(), u'bar')
self.assertEqual(len(warnings), 1)
self.assertEqual(warnings[0], DeprecationWarning)
class TestCurrentWidget(PlacelessSetup, unittest.TestCase):
_WidgetFactory = BrowserWidget
def setUp(self):
PlacelessSetup.setUp(self)
self._widget = BrowserWidget(Text(__name__='test'), TestRequest())
widget.warn = warn
browserwidget.warn = warn
global warnings
warnings = []
def test_haveInput(self):
self.assertEqual(len(warnings), 0)
self.failIf(self._widget.haveData())
self.assertEqual(len(warnings), 1)
self.assertEqual(warnings[0], DeprecationWarning)
def test_getData(self):
self._widget.request.form['field.test'] = u'foo'
self.assertEqual(len(warnings), 0)
self.assertEqual(self._widget.getData(), u'foo')
self.assertEqual(len(warnings), 1)
self.assertEqual(warnings[0], DeprecationWarning)
def test_setData(self):
self.assertEqual(len(warnings), 0)
self._widget.setData('foo')
self.assertEqual(len(warnings), 1)
self.assertEqual(warnings[0], DeprecationWarning)
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestOldWidget),
unittest.makeSuite(TestCurrentWidget)))
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
=== Zope3/src/zope/app/browser/form/tests/test_browserwidget.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/browser/form/tests/test_browserwidget.py:1.14 Tue Jul 15 12:08:51 2003
+++ Zope3/src/zope/app/browser/form/tests/test_browserwidget.py Wed Aug 13 17:28:04 2003
@@ -62,10 +62,10 @@
self._widget.context.required = True
self.failUnless(self._widget.required)
- def test_haveData(self):
- self.failUnless(self._widget.haveData())
+ def test_hasInput(self):
+ self.failUnless(self._widget.hasInput())
del self._widget.request.form['field.foo']
- self.failIf(self._widget.haveData())
+ self.failIf(self._widget.hasInput())
def testProperties(self):
self.assertEqual(self._widget.getValue('tag'), 'input')
@@ -77,7 +77,7 @@
value = 'Foo Value'
check_list = ('type="text"', 'id="field.foo"', 'name="field.foo"',
'value="Foo Value"')
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
self.verifyResult(self._widget(), check_list)
check_list = ('type="hidden"',) + check_list[1:]
self.verifyResult(self._widget.hidden(), check_list)
@@ -148,36 +148,55 @@
request.form['field.foo'] = 'val'
self.assertEqual(w._showData(), 'val')
- w.setData('Xfoo')
+ w.setRenderedValue('Xfoo')
self.assertEqual(w._showData(), 'foo')
- def test_getData(self):
- self.assertEqual(self._widget.getData(), u'Foo Value')
+ def test_hasValidInput(self):
+ self.assertEqual(self._widget.getInputValue(), u'Foo Value')
self._widget.request.form['field.foo'] = (1, 2)
- self.assertRaises(WidgetInputError, self._widget.getData)
+ self.failIf(self._widget.hasValidInput())
self._widget.request.form['field.foo'] = u'barf!'
- self.assertRaises(ConversionError, self._widget.getData)
+ self.failIf(self._widget.hasValidInput())
del self._widget.request.form['field.foo']
self._widget.context.required = True
- self.assertEqual(self._widget.getData(optional=1), None)
- self.assertRaises(MissingInputError, self._widget.getData)
+ self.failIf(self._widget.hasValidInput())
self._widget.context.required = False
- self.assertEqual(self._widget.getData(optional=1), None)
- self.assertEqual(self._widget.getData(), None)
+ self._widget.request.form['field.foo'] = u''
+ self.failUnless(self._widget.hasValidInput())
+
+ def test_getInputValue(self):
+ self.assertEqual(self._widget.getInputValue(), u'Foo Value')
+
+ self._widget.request.form['field.foo'] = (1, 2)
+ self.assertRaises(WidgetInputError, self._widget.getInputValue)
+
+ self._widget.request.form['field.foo'] = u'barf!'
+ self.assertRaises(ConversionError, self._widget.getInputValue)
+
+ del self._widget.request.form['field.foo']
+ self._widget.context.required = True
+ self.assertRaises(MissingInputError, self._widget.getInputValue)
+
+ self._widget.context.required = False
+ self._widget.request.form['field.foo'] = u''
+ self.assertEqual(self._widget.getInputValue(), None)
def test_applyChanges(self):
self.assertEqual(self._widget.applyChanges(self.content), True)
- def test_haveData(self):
- self.failUnless(self._widget.haveData())
+ def test_hasInput(self):
+ self.failUnless(self._widget.hasInput())
del self._widget.request.form['field.foo']
- self.failIf(self._widget.haveData())
+ self.failIf(self._widget.hasInput())
+ self._widget.request.form['field.foo'] = u'foo'
+ self.failUnless(self._widget.hasInput())
+ # widget has input, even if input is an empty string
self._widget.request.form['field.foo'] = u''
- self.failIf(self._widget.haveData())
+ self.failUnless(self._widget.hasInput())
def test_showData_w_default(self):
field = Text(__name__ = 'foo', title = u"Foo Title", default=u"def")
=== Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py:1.8 Thu Jun 5 10:23:05 2003
+++ Zope3/src/zope/app/browser/form/tests/test_checkboxwidget.py Wed Aug 13 17:28:04 2003
@@ -36,12 +36,12 @@
def testRender(self):
value = 1
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
check_list = ('type="checkbox"', 'id="field.foo"',
'name="field.foo"', 'checked="checked"')
self.verifyResult(self._widget(), check_list)
value = 0
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
check_list = check_list[:-1]
self.verifyResult(self._widget(), check_list)
check_list = ('type="hidden"',) + check_list[1:-1]
@@ -50,13 +50,13 @@
self._widget.extra = 'style="color: red"'
self.verifyResult(self._widget.hidden(), check_list)
- def test_getData(self):
+ def test_getInputValue(self):
self._widget.request.form['field.foo'] = 'on'
- self.assertEqual(self._widget.getData(), True)
+ self.assertEqual(self._widget.getInputValue(), True)
self._widget.request.form['field.foo'] = 'positive'
- self.assertEqual(self._widget.getData(), False)
+ self.assertEqual(self._widget.getInputValue(), False)
del self._widget.request.form['field.foo']
- self.assertEqual(self._widget.getData(), False)
+ self.assertEqual(self._widget.getInputValue(), False)
def test_suite():
=== Zope3/src/zope/app/browser/form/tests/test_datetimewidget.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/form/tests/test_datetimewidget.py:1.1 Wed Mar 26 06:28:53 2003
+++ Zope3/src/zope/app/browser/form/tests/test_datetimewidget.py Wed Aug 13 17:28:04 2003
@@ -18,7 +18,7 @@
from zope.app.datetimeutils import parseDatetimetz
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
from zope.app.browser.form.widget import DatetimeWidget
-from zope.app.interfaces.form import ConversionError
+from zope.app.interfaces.form import ConversionError, WidgetInputError
from zope.schema import Datetime
@@ -27,22 +27,23 @@
_FieldFactory = Datetime
_WidgetFactory = DatetimeWidget
- def test_haveData(self):
+ def test_hasInput(self):
del self._widget.request.form['field.foo']
- self.failIf(self._widget.haveData())
+ self.failIf(self._widget.hasInput())
+ # widget has input, even if input is an empty string
self._widget.request.form['field.foo'] = u''
- self.failIf(self._widget.haveData())
+ self.failUnless(self._widget.hasInput())
self._widget.request.form['field.foo'] = u'2003/03/26 12:00:00'
- self.failUnless(self._widget.haveData())
+ self.failUnless(self._widget.hasInput())
- def test_getData(self):
+ def test_getInputValue(self):
TEST_DATE= u'2003/03/26 12:00:00'
self._widget.request.form['field.foo'] = u''
- self.assertEquals(self._widget.getData(optional=1), None)
+ self.assertRaises(WidgetInputError, self._widget.getInputValue)
self._widget.request.form['field.foo'] = TEST_DATE
- self.assertEquals(self._widget.getData(), parseDatetimetz(TEST_DATE))
+ self.assertEquals(self._widget.getInputValue(), parseDatetimetz(TEST_DATE))
self._widget.request.form['field.foo'] = u'abc'
- self.assertRaises(ConversionError, self._widget.getData)
+ self.assertRaises(ConversionError, self._widget.getInputValue)
def test_suite():
=== Zope3/src/zope/app/browser/form/tests/test_datewidget.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/form/tests/test_datewidget.py:1.1 Tue Aug 12 14:18:05 2003
+++ Zope3/src/zope/app/browser/form/tests/test_datewidget.py Wed Aug 13 17:28:04 2003
@@ -18,7 +18,7 @@
from zope.app.datetimeutils import parseDatetimetz
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
from zope.app.browser.form.widget import DateWidget
-from zope.app.interfaces.form import ConversionError
+from zope.app.interfaces.form import ConversionError, WidgetInputError
from zope.schema import Date
@@ -27,24 +27,24 @@
_FieldFactory = Date
_WidgetFactory = DateWidget
- def test_haveData(self):
+ def test_hasInput(self):
del self._widget.request.form['field.foo']
- self.failIf(self._widget.haveData())
+ self.failIf(self._widget.hasInput())
self._widget.request.form['field.foo'] = u''
- self.failIf(self._widget.haveData())
+ self.failUnless(self._widget.hasInput())
self._widget.request.form['field.foo'] = u'2003/03/26'
- self.failUnless(self._widget.haveData())
+ self.failUnless(self._widget.hasInput())
- def test_getData(self):
+ def test_getInputValue(self):
TEST_DATE= u'2003/03/26'
self._widget.request.form['field.foo'] = u''
- self.assertEquals(self._widget.getData(optional=1), None)
+ self.assertRaises(WidgetInputError, self._widget.getInputValue)
self._widget.request.form['field.foo'] = TEST_DATE
self.assertEquals(
- self._widget.getData(),
+ self._widget.getInputValue(),
parseDatetimetz(TEST_DATE).date())
self._widget.request.form['field.foo'] = u'abc'
- self.assertRaises(ConversionError, self._widget.getData)
+ self.assertRaises(ConversionError, self._widget.getInputValue)
def test_suite():
=== Zope3/src/zope/app/browser/form/tests/test_editview.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/browser/form/tests/test_editview.py:1.12 Sun Jul 13 02:47:18 2003
+++ Zope3/src/zope/app/browser/form/tests/test_editview.py Wed Aug 13 17:28:04 2003
@@ -136,7 +136,7 @@
self.assertEqual(c.foo, u'r foo')
self.assertEqual(c.bar, u'r bar')
self.assertEqual(c.a , u'c a')
- self.assertEqual(c.b , None)
+ self.assertEqual(c.b , u'c b') # missing from form - unchanged
self.assertEqual(c.getbaz(), u'r baz')
# Verify that calling update multiple times has no effect
=== Zope3/src/zope/app/browser/form/tests/test_filewidget.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/form/tests/test_filewidget.py:1.6 Thu Jun 5 10:23:05 2003
+++ Zope3/src/zope/app/browser/form/tests/test_filewidget.py Wed Aug 13 17:28:04 2003
@@ -43,7 +43,7 @@
def testRender(self):
value = 'Foo Value'
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
check_list = ('type="file"', 'id="field.foo"', 'name="field.foo"',
'size="20"')
=== Zope3/src/zope/app/browser/form/tests/test_floatwidget.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/form/tests/test_floatwidget.py:1.1 Mon Jan 20 11:23:38 2003
+++ Zope3/src/zope/app/browser/form/tests/test_floatwidget.py Wed Aug 13 17:28:04 2003
@@ -17,7 +17,7 @@
from unittest import main, makeSuite
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
from zope.app.browser.form.widget import FloatWidget
-from zope.app.interfaces.form import ConversionError
+from zope.app.interfaces.form import ConversionError, WidgetInputError
from zope.schema import Float
@@ -26,21 +26,22 @@
_FieldFactory = Float
_WidgetFactory = FloatWidget
- def test_haveData(self):
+ def test_hasInput(self):
del self._widget.request.form['field.foo']
- self.failIf(self._widget.haveData())
+ self.failIf(self._widget.hasInput())
+ # widget has input, even if input is an empty string
self._widget.request.form['field.foo'] = u''
- self.failIf(self._widget.haveData())
+ self.failUnless(self._widget.hasInput())
self._widget.request.form['field.foo'] = u'123'
- self.failUnless(self._widget.haveData())
+ self.failUnless(self._widget.hasInput())
- def test_getData(self):
+ def test_getInputValue(self):
self._widget.request.form['field.foo'] = u''
- self.assertEquals(self._widget.getData(optional=1), None)
+ self.assertRaises(WidgetInputError, self._widget.getInputValue)
self._widget.request.form['field.foo'] = u'123.45'
- self.assertEquals(self._widget.getData(), 123.45)
+ self.assertEquals(self._widget.getInputValue(), 123.45)
self._widget.request.form['field.foo'] = u'abc'
- self.assertRaises(ConversionError, self._widget.getData)
+ self.assertRaises(ConversionError, self._widget.getInputValue)
def test_suite():
=== Zope3/src/zope/app/browser/form/tests/test_intwidget.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/form/tests/test_intwidget.py:1.1 Mon Jan 20 11:23:38 2003
+++ Zope3/src/zope/app/browser/form/tests/test_intwidget.py Wed Aug 13 17:28:04 2003
@@ -17,7 +17,7 @@
from unittest import main, makeSuite
from zope.app.browser.form.tests.test_browserwidget import BrowserWidgetTest
from zope.app.browser.form.widget import IntWidget
-from zope.app.interfaces.form import ConversionError
+from zope.app.interfaces.form import ConversionError, WidgetInputError
from zope.schema import Int
@@ -26,21 +26,22 @@
_FieldFactory = Int
_WidgetFactory = IntWidget
- def test_haveData(self):
+ def test_hasInput(self):
del self._widget.request.form['field.foo']
- self.failIf(self._widget.haveData())
+ self.failIf(self._widget.hasInput())
+ # widget has input, even if input is an empty string
self._widget.request.form['field.foo'] = u''
- self.failIf(self._widget.haveData())
+ self.failUnless(self._widget.hasInput())
self._widget.request.form['field.foo'] = u'123'
- self.failUnless(self._widget.haveData())
+ self.failUnless(self._widget.hasInput())
- def test_getData(self):
+ def test_getInputValue(self):
self._widget.request.form['field.foo'] = u''
- self.assertEquals(self._widget.getData(optional=1), None)
+ self.assertRaises(WidgetInputError, self._widget.getInputValue)
self._widget.request.form['field.foo'] = u'123'
- self.assertEquals(self._widget.getData(), 123)
+ self.assertEquals(self._widget.getInputValue(), 123)
self._widget.request.form['field.foo'] = u'abc'
- self.assertRaises(ConversionError, self._widget.getData)
+ self.assertRaises(ConversionError, self._widget.getInputValue)
def test_suite():
=== Zope3/src/zope/app/browser/form/tests/test_listwidget.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/form/tests/test_listwidget.py:1.7 Thu Jun 5 10:23:05 2003
+++ Zope3/src/zope/app/browser/form/tests/test_listwidget.py Wed Aug 13 17:28:04 2003
@@ -58,7 +58,7 @@
check_list = ('select', 'id="field.foo"', 'name="field.foo"',
'size="5"', 'option', 'value="foo"', '>foo<',
'value="foo"', '>bar<', 'selected="selected"')
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
self.verifyResult(self._widget(), check_list)
check_list = ('type="hidden"', 'id="field.foo"', 'name="field.foo"',
=== Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py:1.7 Thu Jun 5 10:23:05 2003
+++ Zope3/src/zope/app/browser/form/tests/test_multicheckboxwidget.py Wed Aug 13 17:28:04 2003
@@ -56,7 +56,7 @@
def testRender(self):
value = 'bar'
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
check_list = ('type="checkbox"', 'id="field.foo"',
'name="field.foo"', 'value="bar"', 'bar',
'value="foo"', 'foo', 'checked="checked"')
=== Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py:1.7 Thu Jun 5 10:23:05 2003
+++ Zope3/src/zope/app/browser/form/tests/test_multilistwidget.py Wed Aug 13 17:28:04 2003
@@ -53,7 +53,7 @@
def testRender(self):
value = 'foo'
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
check_list = ('select', 'id="field.foo"', 'name="field.foo"',
'size="5"', 'option', 'value="foo"', '>foo<',
'value="foo"', '>bar<', 'selected="selected"',
=== Zope3/src/zope/app/browser/form/tests/test_objectwidget.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/browser/form/tests/test_objectwidget.py:1.3 Mon Aug 4 10:54:28 2003
+++ Zope3/src/zope/app/browser/form/tests/test_objectwidget.py Wed Aug 13 17:28:04 2003
@@ -57,7 +57,7 @@
self.request.form['field.foo'] = u'Foo Value'
self._widget = self._WidgetFactory(self.field, self.request)
- def test_haveData(self):
+ def test_hasInput(self):
# doesn't work with subfields
pass
@@ -89,7 +89,7 @@
self.request.form['field.foo.name'] = u'Foo Name'
self.request.form['field.foo.email'] = u'foo at foo.test'
widget = self._WidgetFactory(self.field, self.request)
- widget.setData(self.content.foo)
+ widget.setRenderedValue(self.content.foo)
self.assertEqual(widget.applyChanges(self.content), False)
self.assertEqual(hasattr(self.content, 'foo'), True)
@@ -100,7 +100,7 @@
def test_new(self):
request = TestRequest()
widget = ObjectWidget(self.field, request, TestContact)
- self.assertEquals(int(widget.haveData()), 0)
+ self.assertEquals(int(widget.hasInput()), 0)
check_list = (
'input', 'name="field.foo.name"',
'input', 'name="field.foo.email"'
@@ -113,8 +113,8 @@
'field.foo.email': u'fred at fred.com'
})
widget = ObjectWidget(self.field, request, TestContact)
- self.assertEquals(int(widget.haveData()), 1)
- o = widget.getData()
+ self.assertEquals(int(widget.hasInput()), 1)
+ o = widget.getInputValue()
self.assertEquals(hasattr(o, 'name'), 1)
self.assertEquals(o.name, u'fred')
self.assertEquals(o.email, u'fred at fred.com')
=== Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py:1.7 Thu Jun 5 10:23:05 2003
+++ Zope3/src/zope/app/browser/form/tests/test_passwordwidget.py Wed Aug 13 17:28:04 2003
@@ -35,7 +35,7 @@
def testRender(self):
value = 'Foo Value'
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
check_list = ('type="password"', 'id="field.foo"',
'name="field.foo"', 'value=""', 'size="20"')
self.verifyResult(self._widget(), check_list)
=== Zope3/src/zope/app/browser/form/tests/test_radiowidget.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/browser/form/tests/test_radiowidget.py:1.8 Thu Jun 5 10:23:05 2003
+++ Zope3/src/zope/app/browser/form/tests/test_radiowidget.py Wed Aug 13 17:28:04 2003
@@ -57,7 +57,7 @@
def testRender(self):
value = 'bar'
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
check_list = ('type="radio"', 'id="field.foo.0"',
'name="field.foo"', 'value="bar"', 'bar',
'value="foo"', 'foo', 'checked="checked"')
=== Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py:1.3 Sun Jul 13 02:47:18 2003
+++ Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py Wed Aug 13 17:28:04 2003
@@ -45,42 +45,42 @@
provideView(ITextLine, 'edit', IBrowserPresentation, [TextWidget])
def test_haveNoData(self):
- self.failIf(self._widget.haveData())
+ self.failIf(self._widget.hasInput())
- def test_haveData(self):
+ def test_hasInput(self):
self._widget.request.form['field.foo.0.bar'] = u'hi, mum'
- self.failUnless(self._widget.haveData())
+ self.failUnless(self._widget.hasInput())
def test_list(self):
self.field = List(__name__=u'foo', value_type=TextLine(__name__=u'bar'))
request = TestRequest()
widget = ListSequenceWidget(self.field, request)
- self.assertEquals(int(widget.haveData()), 0)
- self.assertEquals(widget.getData(), [])
+ self.assertEquals(int(widget.hasInput()), 0)
+ self.assertEquals(widget.getInputValue(), [])
request = TestRequest(form={'field.foo.add': u'Add bar'})
widget = ListSequenceWidget(self.field, request)
- self.assertEquals(int(widget.haveData()), 1)
- self.assertRaises(ValidationError, widget.getData)
+ self.assertEquals(int(widget.hasInput()), 1)
+ self.assertRaises(ValidationError, widget.getInputValue)
request = TestRequest(form={'field.foo.0.bar': u'Hello world!'})
widget = ListSequenceWidget(self.field, request)
- self.assertEquals(int(widget.haveData()), 1)
- self.assertEquals(widget.getData(), [u'Hello world!'])
+ self.assertEquals(int(widget.hasInput()), 1)
+ self.assertEquals(widget.getInputValue(), [u'Hello world!'])
def test_new(self):
request = TestRequest()
widget = TupleSequenceWidget(self.field, request)
- self.assertEquals(int(widget.haveData()), 0)
- self.assertEquals(widget.getData(), ())
+ self.assertEquals(int(widget.hasInput()), 0)
+ self.assertEquals(widget.getInputValue(), ())
check_list = ('input', 'name="field.foo.add"')
self.verifyResult(widget(), check_list)
def test_add(self):
request = TestRequest(form={'field.foo.add': u'Add bar'})
widget = TupleSequenceWidget(self.field, request)
- self.assertEquals(int(widget.haveData()), 1)
- self.assertRaises(ValidationError, widget.getData)
+ self.assertEquals(int(widget.hasInput()), 1)
+ self.assertRaises(ValidationError, widget.getInputValue)
check_list = (
'checkbox', 'field.foo.remove_0', 'input', 'field.foo.0.bar',
'submit', 'submit', 'field.foo.add'
@@ -90,24 +90,24 @@
def test_request(self):
request = TestRequest(form={'field.foo.0.bar': u'Hello world!'})
widget = TupleSequenceWidget(self.field, request)
- self.assertEquals(int(widget.haveData()), 1)
- self.assertEquals(widget.getData(), (u'Hello world!',))
+ self.assertEquals(int(widget.hasInput()), 1)
+ self.assertEquals(widget.getInputValue(), (u'Hello world!',))
def test_existing(self):
request = TestRequest()
widget = TupleSequenceWidget(self.field, request)
- widget.setData((u'existing',))
- self.assertEquals(int(widget.haveData()), 1)
- self.assertEquals(widget.getData(), (u'existing',))
+ widget.setRenderedValue((u'existing',))
+ self.assertEquals(int(widget.hasInput()), 1)
+ self.assertEquals(widget.getInputValue(), (u'existing',))
check_list = (
'checkbox', 'field.foo.remove_0', 'input', 'field.foo.0.bar',
'existing',
'submit', 'submit', 'field.foo.add'
)
self.verifyResult(widget(), check_list, inorder=True)
- widget.setData((u'existing', u'second'))
- self.assertEquals(int(widget.haveData()), 1)
- self.assertEquals(widget.getData(), (u'existing', u'second'))
+ widget.setRenderedValue((u'existing', u'second'))
+ self.assertEquals(int(widget.hasInput()), 1)
+ self.assertEquals(widget.getInputValue(), (u'existing', u'second'))
check_list = (
'checkbox', 'field.foo.remove_0', 'input', 'field.foo.0.bar',
'existing',
@@ -121,8 +121,8 @@
request = TestRequest(form={'field.foo.remove_0': u'Hello world!',
'field.foo.0.bar': u'existing', 'field.foo.1.bar': u'second'})
widget = TupleSequenceWidget(self.field, request)
- widget.setData((u'existing', u'second'))
- self.assertEquals(widget.getData(), (u'second',))
+ widget.setRenderedValue((u'existing', u'second'))
+ self.assertEquals(widget.getInputValue(), (u'second',))
check_list = (
'checkbox', 'field.foo.remove_0', 'input', 'field.foo.0.bar',
'second',
@@ -134,8 +134,8 @@
request = TestRequest()
self.field.min_length = 2
widget = TupleSequenceWidget(self.field, request)
- widget.setData((u'existing',))
- self.assertEquals(widget.getData(), (u'existing',))
+ widget.setRenderedValue((u'existing',))
+ self.assertEquals(widget.getInputValue(), (u'existing',))
check_list = (
'input', 'field.foo.0.bar', 'existing',
'input', 'field.foo.1.bar', 'value=""',
@@ -149,8 +149,8 @@
request = TestRequest()
self.field.max_length = 1
widget = TupleSequenceWidget(self.field, request)
- widget.setData((u'existing',))
- self.assertEquals(widget.getData(), (u'existing',))
+ widget.setRenderedValue((u'existing',))
+ self.assertEquals(widget.getInputValue(), (u'existing',))
s = widget()
self.assertEquals(s.find('field.foo.add'), -1)
@@ -158,7 +158,7 @@
self.field = Tuple(__name__=u'foo', value_type=TextLine())
request = TestRequest()
widget = TupleSequenceWidget(self.field, request)
- widget.setData((u'existing',))
+ widget.setRenderedValue((u'existing',))
s = widget()
check_list = (
'input', '"field.foo.0."', 'existing',
=== Zope3/src/zope/app/browser/form/tests/test_setprefix.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/browser/form/tests/test_setprefix.py:1.5 Wed Apr 30 19:37:52 2003
+++ Zope3/src/zope/app/browser/form/tests/test_setprefix.py Wed Aug 13 17:28:04 2003
@@ -30,13 +30,13 @@
self._widget.setPrefix('spam')
def testGetData(self):
- self.assertEqual(self._widget.getData(), u'Foo Value')
+ self.assertEqual(self._widget.getInputValue(), u'Foo Value')
def testRender(self):
value = 'Foo Value 2'
check_list = ('type="text"', 'id="spam.foo"', 'name="spam.foo"',
'value="Foo Value 2"', 'size="20"')
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
self._verifyResult(self._widget(), check_list)
check_list = ('type="hidden"',) + check_list[1:-1]
self._verifyResult(self._widget.hidden(), check_list)
=== Zope3/src/zope/app/browser/form/tests/test_textareawidget.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/form/tests/test_textareawidget.py:1.7 Thu Jun 5 10:23:05 2003
+++ Zope3/src/zope/app/browser/form/tests/test_textareawidget.py Wed Aug 13 17:28:04 2003
@@ -34,7 +34,7 @@
def testRender(self):
value = "Foo Value"
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
check_list = ('rows="15"', 'cols="60"', 'id="field.foo"',
'name="field.foo"', 'textarea')
self.verifyResult(self._widget(), check_list)
=== Zope3/src/zope/app/browser/form/tests/test_textwidget.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/form/tests/test_textwidget.py:1.6 Thu Jun 5 10:23:05 2003
+++ Zope3/src/zope/app/browser/form/tests/test_textwidget.py Wed Aug 13 17:28:04 2003
@@ -35,7 +35,7 @@
def testRender(self):
value = 'Foo Value'
- self._widget.setData(value)
+ self._widget.setRenderedValue(value)
check_list = ('type="text"', 'id="field.foo"', 'name="field.foo"',
'value="Foo Value"', 'size="20"')
self.verifyResult(self._widget(), check_list)
=== Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py 1.23 => 1.24 ===
--- Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py:1.23 Wed Jun 18 11:09:16 2003
+++ Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py Wed Aug 13 17:28:04 2003
@@ -240,25 +240,25 @@
def test_display(self):
bound = self.makeField()
w = getView(bound, "display", self.makeRequest())
- w.setData(bound.context.f)
+ w.setRenderedValue(bound.context.f)
self.assertEqual(w(), "splat")
def test_display_with_form_value(self):
bound = self.makeField()
request = self.makeRequest('field.f=foobar')
w = getView(bound, "display", request)
- self.assert_(w.haveData())
+ self.assert_(w.hasInput())
self.assertEqual(w(), "foobar")
def setup_edit(self, bound):
w = getView(bound, "edit", self.makeRequest())
- w.setData(bound.context.f)
- self.assert_(not w.haveData())
+ w.setRenderedValue(bound.context.f)
+ self.assert_(not w.hasInput())
return w
def test_edit(self, extraChecks=[]):
w = self.setup_edit(self.makeField())
- self.assertEqual(w.getData(), None)
+ self.assertEqual(w.getInputValue(), None)
self.verifyResult(w(), [
'selected="selected"',
'id="field.f"',
@@ -311,20 +311,20 @@
bound = self.makeField()
request = self.makeRequest('field.f=foobar')
w = getView(bound, "edit", request)
- self.assert_(w.haveData())
- self.assertEqual(w.getData(), "foobar")
+ self.assert_(w.hasInput())
+ self.assertEqual(w.getInputValue(), "foobar")
self.assert_(isinstance(w, vocabularywidget.VocabularyEditWidget))
def test_edit_with_modified_empty_value(self):
# This tests that emptying a value via the form when there's a
# non-empty value for the field on the content object will
- # report haveData() properly.
+ # report hasInput() properly.
bound = self.makeField()
bound.context.f = "splat"
w = getView(bound, "edit", self.makeRequest(
'field.f-empty-marker='))
- self.assert_(w.haveData())
- self.assertEqual(w.getData(), None) # XXX might be []...
+ self.assert_(w.hasInput())
+ self.assertEqual(w.getInputValue(), None) # XXX might be []...
class SingleSelectionTests(SingleSelectionTestsBase):
"""Test single-selection with the selection-box widget."""
@@ -357,7 +357,7 @@
bound = self.makeField()
del bound.context.f
w = getView(bound, "display", self.makeRequest())
- self.assert_(not w.haveData())
+ self.assert_(not w.hasInput())
self.verifyResult(w(), [
'<span',
'id="field.f"',
@@ -368,8 +368,8 @@
def test_display_with_value(self):
bound = self.makeField(value=["foobar", "frob"])
w = getView(bound, "display", self.makeRequest())
- w.setData(bound.context.f)
- self.assert_(not w.haveData())
+ w.setRenderedValue(bound.context.f)
+ self.assert_(not w.hasInput())
self.verifyResult(w(), [
'<ol',
'id="field.f"',
@@ -390,7 +390,7 @@
bound = self.makeField(value=["foobar", "frob"])
request = self.makeRequest('field.f:list=splat')
w = getView(bound, "display", request)
- self.assert_(w.haveData())
+ self.assert_(w.hasInput())
s = w()
self.verifyResult(s, [
'<ol',
@@ -407,7 +407,7 @@
def test_edit(self):
bound = self.makeField()
w = getView(bound, "edit", self.makeRequest())
- self.assert_(not w.haveData())
+ self.assert_(not w.hasInput())
self.verifyResult(w(), [
'id="field.f"',
'name="field.f:list"',
@@ -439,8 +439,8 @@
bound = self.makeField()
request = self.makeRequest('field.f:list=foobar&field.f:list=splat')
w = getView(bound, "edit", request)
- self.assert_(w.haveData())
- L = w.getData()
+ self.assert_(w.hasInput())
+ L = w.getInputValue()
L.sort()
self.assertEqual(L, ["foobar", "splat"])
@@ -468,7 +468,7 @@
def test_query_input_section(self):
bound = self.makeField()
w = getView(bound, "edit", self.makeRequest())
- w.setData(bound.context.f)
+ w.setRenderedValue(bound.context.f)
checks = [
"this-is-query-input",
]
@@ -478,7 +478,7 @@
def test_query_output_section_without_results(self):
bound = self.makeField()
w = getView(bound, "edit", self.makeRequest())
- w.setData(bound.context.f)
+ w.setRenderedValue(bound.context.f)
checks = [
"query-results-go-here",
]
@@ -488,7 +488,7 @@
def test_query_output_section_with_results(self):
bound = self.makeField()
w = getView(bound, "edit", self.makeRequest("field.f-query=foo"))
- w.setData(bound.context.f)
+ w.setRenderedValue(bound.context.f)
checks = [
"query-results-go-here",
]
More information about the Zope3-Checkins
mailing list