[Zope3-checkins] CVS: Zope3/src/zope/app/form/browser/tests -
test_browserwidget.py:1.3.2.1 test_multicheckboxwidget.py:1.4.2.1
test_objectwidget.py:1.2.8.1 test_radiowidget.py:1.3.2.1
test_sequencewidget.py:1.4.2.1
Martijn Faassen
m.faassen at vet.uu.nl
Tue May 11 05:10:56 EDT 2004
Update of /cvs-repository/Zope3/src/zope/app/form/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv20906/src/zope/app/form/browser/tests
Modified Files:
Tag: faassen-interfaces-branch
test_browserwidget.py test_multicheckboxwidget.py
test_objectwidget.py test_radiowidget.py
test_sequencewidget.py
Log Message:
Sync up with changes in HEAD (so I can generate up to date patch file).
=== Zope3/src/zope/app/form/browser/tests/test_browserwidget.py 1.3 => 1.3.2.1 ===
--- Zope3/src/zope/app/form/browser/tests/test_browserwidget.py:1.3 Sat Apr 24 19:19:43 2004
+++ Zope3/src/zope/app/form/browser/tests/test_browserwidget.py Tue May 11 05:10:21 2004
@@ -38,11 +38,11 @@
_FieldFactory = Text
_WidgetFactory = BrowserWidget
- def setUpContent(self, desc=u''):
+ def setUpContent(self, desc=u'', title=u'Foo Title'):
class ITestContent(Interface):
foo = self._FieldFactory(
- title = u"Foo Title",
- description = desc,
+ title=title,
+ description=desc,
)
class TestObject:
implements(ITestContent)
@@ -88,20 +88,12 @@
self.verifyResult(self._widget.hidden(), check_list)
def testLabel(self):
- label = ' '.join(self._widget.label().strip().split())
- self.assertEqual(label, '<label for="field.foo">Foo Title</label>')
+ self.setUpContent(title=u'Foo:')
+ self.assertEqual(self._widget.label, u'Foo:')
- self.setUpContent(desc=u"Foo Description")
- label = ' '.join(self._widget.label().strip().split())
- self.assertEqual(label,
- '<label for="field.foo" title="Foo Description">'
- 'Foo Title</label>'
- )
-
- def testDescription(self):
+ def testHint(self):
self.setUpContent(desc=u'Foo Description')
- description = ' '.join(self._widget.description.strip().split())
- self.assertEqual(description, u'Foo Description')
+ self.assertEqual(self._widget.hint, u'Foo Description')
def testTranslatedLabel(self):
path = os.path.dirname(zope.app.form.browser.tests.__file__)
@@ -110,26 +102,8 @@
domain = TranslationDomain('zope')
domain.addCatalog(catalog)
ztapi.provideUtility(ITranslationDomain, domain, 'zope')
- label = ' '.join(self._widget.label().strip().split())
- 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())
- self.assertEqual(row, '<divclass="labelrequired">%s</div>'
- '<divclass="field">%s</div>' % (label, value))
+ self.assertEqual(self._widget.label, 'oofay itletay')
- 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())
- self.assertEqual(row, '<divclass="label">%s</div>'
- '<divclass="field">%s</div>' % (label, value))
class TestWidget(BrowserWidget):
=== Zope3/src/zope/app/form/browser/tests/test_multicheckboxwidget.py 1.4 => 1.4.2.1 ===
--- Zope3/src/zope/app/form/browser/tests/test_multicheckboxwidget.py:1.4 Thu May 6 12:13:41 2004
+++ Zope3/src/zope/app/form/browser/tests/test_multicheckboxwidget.py Tue May 11 05:10:21 2004
@@ -34,10 +34,10 @@
_WidgetFactory = MultiCheckBoxWidget
_FieldFactory = List
- def setUpContent(self, desc=u''):
+ def setUpContent(self, desc=u'', title=u'Foo Title'):
class ITestContent(Interface):
foo = self._FieldFactory(
- title = u'Foo Title',
+ title=title,
description=desc,
value_type=Choice(values=[u'foo', u'bar'])
)
=== Zope3/src/zope/app/form/browser/tests/test_objectwidget.py 1.2 => 1.2.8.1 ===
--- Zope3/src/zope/app/form/browser/tests/test_objectwidget.py:1.2 Wed Mar 17 12:37:06 2004
+++ Zope3/src/zope/app/form/browser/tests/test_objectwidget.py Tue May 11 05:10:21 2004
@@ -25,12 +25,12 @@
from zope.app.form.interfaces import IInputWidget
from zope.app.form.browser import TextWidget, ObjectWidget
from zope.interface.verify import verifyClass
-
from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
class ITestContact(Interface):
name = TextLine()
email = TextLine()
+
class TestContact:
implements(ITestContact)
@@ -46,14 +46,14 @@
kw.update({'factory': TestContact})
return ObjectWidget(context, request, **kw)
- def setUpContent(self, desc=u''):
+ def setUpContent(self, desc=u'', title=u'Foo Title'):
ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget)
class ITestContent(Interface):
foo = self._FieldFactory(
ITestContact,
- title = u"Foo Title",
- description = desc
+ title=title,
+ description=desc
)
class TestObject:
implements(ITestContent)
@@ -63,7 +63,7 @@
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
@@ -104,32 +104,6 @@
self.assertEqual(self.content.foo.name, u'Foo Name')
self.assertEqual(self.content.foo.email, u'foo at foo.test')
- def test_new(self):
- request = TestRequest()
- widget = ObjectWidget(self.field, request, TestContact)
- self.assertEquals(int(widget.hasInput()), 0)
- check_list = (
- 'input', 'name="field.foo.name"',
- 'input', 'name="field.foo.email"'
- )
- self.verifyResult(widget(), check_list)
-
- def test_edit(self):
- request = TestRequest(form={
- 'field.foo.name': u'fred',
- 'field.foo.email': u'fred at fred.com'
- })
- widget = ObjectWidget(self.field, request, TestContact)
- 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')
- check_list = (
- 'input', 'name="field.foo.name"', 'value="fred"',
- 'input', 'name="field.foo.email"', 'value="fred at fred.com"',
- )
- self.verifyResult(widget(), check_list)
def test_suite():
return unittest.TestSuite((
=== Zope3/src/zope/app/form/browser/tests/test_radiowidget.py 1.3 => 1.3.2.1 ===
--- Zope3/src/zope/app/form/browser/tests/test_radiowidget.py:1.3 Sat Apr 24 19:19:43 2004
+++ Zope3/src/zope/app/form/browser/tests/test_radiowidget.py Tue May 11 05:10:21 2004
@@ -33,7 +33,7 @@
class RadioWidgetTest(BrowserWidgetTest):
"""Documents and tests the radio widget.
-
+
>>> verifyClass(IInputWidget, RadioWidget)
True
"""
@@ -41,11 +41,11 @@
_FieldFactory = Choice
_WidgetFactory = RadioWidget
- def setUpContent(self, desc=u''):
+ def setUpContent(self, desc=u'', title=u'Foo Title'):
class ITestContent(Interface):
foo = self._FieldFactory(
- title = u"Foo Title",
- description = desc,
+ title=title,
+ description=desc,
values=(u'foo', u'bar')
)
class TestObject:
@@ -101,33 +101,6 @@
self._widget.extra = 'style="color: red"'
self.verifyResult(self._widget.hidden(), check_list)
- def testLabel(self):
- 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__)
- catalog = GettextMessageCatalog(
- 'pl', 'zope', os.path.join(path, 'testlabeltranslation.mo'))
- domain = TranslationDomain('zope')
- domain.addCatalog(catalog)
- ztapi.provideUtility(ITranslationDomain, domain, 'zope')
- label = ' '.join(self._widget.label().strip().split())
- self.assertEqual(label, '<label for="field.foo">oofay itletay</label>')
-
- def testRowRequired(self):
- self._widget.request.form.clear()
- self._widget.context.required = True
- 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
- 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.4 => 1.4.2.1 ===
--- Zope3/src/zope/app/form/browser/tests/test_sequencewidget.py:1.4 Thu May 6 12:13:41 2004
+++ Zope3/src/zope/app/form/browser/tests/test_sequencewidget.py Tue May 11 05:10:21 2004
@@ -41,11 +41,11 @@
True
"""
- def setUpContent(self, desc=u''):
+ def setUpContent(self, desc=u'', title=u'Foo Title'):
class ITestContent(Interface):
foo = self._FieldFactory(
- title = u"Foo Title",
- description = desc,
+ title=title,
+ description=desc,
)
class TestObject:
implements(ITestContent)
More information about the Zope3-Checkins
mailing list