[Zope3-checkins] CVS: Zope3/src/zope/app/form/browser/tests -
support.py:1.2 test_browserwidget.py:1.3
test_multicheckboxwidget.py:1.3 test_radiowidget.py:1.3
test_sequencewidget.py:1.3 test_listwidget.py:NONE
test_multilistwidget.py:NONE test_vocabularywidget.py:NONE
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sat Apr 24 19:19:44 EDT 2004
Update of /cvs-repository/Zope3/src/zope/app/form/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv30169/src/zope/app/form/browser/tests
Modified Files:
support.py test_browserwidget.py test_multicheckboxwidget.py
test_radiowidget.py test_sequencewidget.py
Removed Files:
test_listwidget.py test_multilistwidget.py
test_vocabularywidget.py
Log Message:
Removed Enumerated widgets. Refactored vocabulary widgets to be views of
fields and vocabularies. Updated tests.
=== Zope3/src/zope/app/form/browser/tests/support.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/form/browser/tests/support.py:1.1 Sat Mar 13 20:11:36 2004
+++ Zope3/src/zope/app/form/browser/tests/support.py Sat Apr 24 19:19:43 2004
@@ -11,11 +11,11 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""General test support.
-"""General test support."""
-
-
-class VerifyResults:
+$Id$
+"""
+class VerifyResults(object):
"""Mix-in for test classes with helpers for checking string data."""
def verifyResult(self, result, check_list, inorder=False):
=== Zope3/src/zope/app/form/browser/tests/test_browserwidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_browserwidget.py:1.2 Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_browserwidget.py Sat Apr 24 19:19:43 2004
@@ -49,6 +49,7 @@
self.content = TestObject()
field = ITestContent['foo']
+ field = field.bind(self.content)
request = TestRequest(HTTP_ACCEPT_LANGUAGE='pl')
request.form['field.foo'] = u'Foo Value'
self._widget = self._WidgetFactory(field, request)
=== Zope3/src/zope/app/form/browser/tests/test_multicheckboxwidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_multicheckboxwidget.py:1.2 Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_multicheckboxwidget.py Sat Apr 24 19:19:43 2004
@@ -15,6 +15,9 @@
$Id$
"""
import unittest, doctest
+from zope.interface import Interface, implements
+from zope.publisher.browser import TestRequest
+from zope.schema import Choice, Sequence
from zope.app.form.interfaces import IInputWidget
from zope.app.form.browser import MultiCheckBoxWidget
@@ -29,10 +32,25 @@
"""
_WidgetFactory = MultiCheckBoxWidget
+ _FieldFactory = Sequence
- def setUp(self):
- BrowserWidgetTest.setUp(self)
- self._widget.context.allowed_values = (u'foo', u'bar')
+ def setUpContent(self, desc=u''):
+ class ITestContent(Interface):
+ foo = self._FieldFactory(
+ title = u'Foo Title',
+ description=desc,
+ value_type=Choice(values=[u'foo', u'bar'])
+ )
+ class TestObject:
+ implements(ITestContent)
+
+ self.content = TestObject()
+ field = ITestContent['foo']
+ field = field.bind(self.content)
+ request = TestRequest(HTTP_ACCEPT_LANGUAGE='pl',
+ form={'field.foo': u'bar'})
+ self._widget = self._WidgetFactory(field, field.value_type.vocabulary,
+ request)
def testProperties(self):
self.assertEqual(self._widget.cssClass, "")
@@ -41,7 +59,7 @@
def testRenderItem(self):
- check_list = ('type="checkbox"', 'id="field.bar"',
+ check_list = ('type="checkbox"', 'id="field.bar.',
'name="field.bar"', 'value="foo"', 'Foo')
self.verifyResult(
self._widget.renderItem(0, 'Foo', 'foo', 'field.bar', None),
@@ -54,22 +72,20 @@
def testRenderItems(self):
- check_list = ('type="checkbox"', 'id="field.foo"',
+ check_list = ('type="checkbox"', 'id="field.foo.',
'name="field.foo"', 'value="bar"', 'bar',
'value="foo"', 'foo', 'checked="checked"')
- self.verifyResult('\n'.join(self._widget.renderItems('bar')),
+ self.verifyResult('\n'.join(self._widget.renderItems(['bar'])),
check_list)
def testRender(self):
- value = 'bar'
- self._widget.setRenderedValue(value)
- check_list = ('type="checkbox"', 'id="field.foo"',
+ check_list = ('type="checkbox"', 'id="field.foo.',
'name="field.foo"', 'value="bar"', 'bar',
'value="foo"', 'foo', 'checked="checked"')
self.verifyResult(self._widget(), check_list)
- check_list = ('type="hidden"', 'id="field.foo"', 'name="field.foo"',
+ check_list = ('type="hidden"', 'id="field.foo', 'name="field.foo:list"',
'value="bar"')
self.verifyResult(self._widget.hidden(), check_list)
check_list = ('style="color: red"',) + check_list
=== Zope3/src/zope/app/form/browser/tests/test_radiowidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_radiowidget.py:1.2 Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_radiowidget.py Sat Apr 24 19:19:43 2004
@@ -16,7 +16,10 @@
"""
import os
import unittest, doctest
+from zope.interface import Interface, implements
from zope.interface.verify import verifyClass
+from zope.publisher.browser import TestRequest
+from zope.schema import Choice
from zope.i18n.interfaces import ITranslationDomain
from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
@@ -35,11 +38,25 @@
True
"""
+ _FieldFactory = Choice
_WidgetFactory = RadioWidget
- def setUp(self):
- BrowserWidgetTest.setUp(self)
- self._widget.context.allowed_values = (u'foo', u'bar')
+ def setUpContent(self, desc=u''):
+ class ITestContent(Interface):
+ foo = self._FieldFactory(
+ title = u"Foo Title",
+ description = desc,
+ values=(u'foo', u'bar')
+ )
+ 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'
+ self._widget = self._WidgetFactory(field, field.vocabulary, request)
def testProperties(self):
self.assertEqual(self._widget.cssClass, "")
@@ -85,8 +102,8 @@
self.verifyResult(self._widget.hidden(), check_list)
def testLabel(self):
- label = ' '.join(self._widget.label().strip().split())
- self.assertEqual(label, 'Foo Title')
+ self.assertEqual(self._widget.label(),
+ '<label for="field.foo">Foo Title</label>')
def testTranslatedLabel(self):
path = os.path.dirname(zope.app.form.browser.tests.__file__)
@@ -96,35 +113,21 @@
domain.addCatalog(catalog)
ztapi.provideUtility(ITranslationDomain, domain, 'zope')
label = ' '.join(self._widget.label().strip().split())
- self.assertEqual(label, 'oofay itletay')
+ self.assertEqual(label, '<label for="field.foo">oofay itletay</label>')
def testRowRequired(self):
self._widget.request.form.clear()
self._widget.context.required = True
- 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="labelrequired">'
- '<labelfor="%s">%s</label>'
- '</div>'
- '<divclass="field"id="%s">'
- '%s'
- '</div>' % (id, label, id, value))
+ self.verifyResultMissing(self._widget(),
+ ['<input name="field.foo-empty-marker" '
+ 'type="hidden" value="1" />\n</div>'])
def testRowNonRequired(self):
self._widget.request.form.clear()
self._widget.context.required = False
- 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))
+ self.verifyResult(self._widget(),
+ ['<input name="field.foo-empty-marker" '
+ 'type="hidden" value="1" />\n</div>'])
def test_suite():
return unittest.TestSuite((
=== Zope3/src/zope/app/form/browser/tests/test_sequencewidget.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/form/browser/tests/test_sequencewidget.py:1.2 Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_sequencewidget.py Sat Apr 24 19:19:43 2004
@@ -11,10 +11,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Sequence Field Widget tests.
+
$Id$
"""
-
import unittest, doctest
from zope.schema import Tuple, List, TextLine
@@ -22,6 +22,7 @@
from zope.publisher.browser import TestRequest
from zope.interface.verify import verifyClass
+from zope.app import zapi
from zope.app.tests import ztapi
from zope.app.form.browser import TextWidget, TupleSequenceWidget
from zope.app.form.browser import ListSequenceWidget
@@ -29,6 +30,7 @@
from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+
class SequenceWidgetTest(BrowserWidgetTest):
"""Documents and tests the tuple and list (sequence) widgets.
@@ -180,6 +182,7 @@
s = widget()
self.verifyResult(s, check_list, inorder=True)
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(SequenceWidgetTest),
@@ -188,5 +191,5 @@
if __name__=='__main__':
unittest.main(defaultTest='test_suite')
-# vim: set filetype=python ts=4 sw=4 et si
+
=== Removed File Zope3/src/zope/app/form/browser/tests/test_listwidget.py ===
=== Removed File Zope3/src/zope/app/form/browser/tests/test_multilistwidget.py ===
=== Removed File Zope3/src/zope/app/form/browser/tests/test_vocabularywidget.py ===
More information about the Zope3-Checkins
mailing list