[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/form/browser/tests/test_objectwidget.py - verified fix for issue 565 and provided test (ported from 3.3 branch)

Christian Theune cvs-admin at zope.org
Sat Jun 17 18:11:32 EDT 2006


Log message for revision 68722:
   - verified fix for issue 565 and provided test (ported from 3.3 branch)
  

Changed:
  U   Zope3/trunk/src/zope/app/form/browser/tests/test_objectwidget.py

-=-
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_objectwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_objectwidget.py	2006-06-17 22:10:04 UTC (rev 68721)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_objectwidget.py	2006-06-17 22:11:28 UTC (rev 68722)
@@ -23,10 +23,11 @@
 from zope.schema.interfaces import ITextLine
 from zope.publisher.browser import TestRequest
 from zope.schema import Object, TextLine
-from zope.app.form.interfaces import IInputWidget
+from zope.app.form.interfaces import IInputWidget, MissingInputError
 from zope.app.form.browser import TextWidget, ObjectWidget
 from zope.interface.verify import verifyClass
 from zope.app.form.browser.tests.test_browserwidget import BrowserWidgetTest
+from zope.app.form.browser.interfaces import IWidgetInputErrorView
 
 class ITestContact(Interface):
     name = TextLine()
@@ -35,6 +36,16 @@
 class TestContact(object):
     implements(ITestContact)
 
+class ObjectWidgetInputErrorView(object):
+    implements(IWidgetInputErrorView)
+
+    def __init__(self, error, request):
+        self.error = error
+        self.request = request
+
+    def snippet(self):
+        return repr(self.error)
+
 class ObjectWidgetTest(BrowserWidgetTest):
     """Documents and tests the object widget.
         
@@ -81,6 +92,18 @@
         self.assertEqual(self.content.foo.name, u'Foo Name')
         self.assertEqual(self.content.foo.email, u'foo at foo.test')
 
+    def test_error(self):
+        ztapi.provideAdapter(
+                required=(MissingInputError, TestRequest),
+                provided=IWidgetInputErrorView,
+                factory=ObjectWidgetInputErrorView)
+
+        widget = self._WidgetFactory(self.field, self.request)
+        self.assertRaises(MissingInputError, widget.getInputValue)
+        error_html = widget.error()
+        self.failUnless("email: <zope.app.form.interfaces.Mis" in error_html)
+        self.failUnless("name: <zope.app.form.interfaces.Miss" in error_html)
+
     def test_applyChangesNoChange(self):
         self.content.foo = TestContact()
         self.content.foo.name = u'Foo Name'



More information about the Zope3-Checkins mailing list