Ignore:
Timestamp:
6 Aug 2010, 09:30:25 (14 years ago)
Author:
uli
Message:

Extend tests. Coverage at 100% :-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.widgets.core/trunk/src/waeup/widgets/core/tests/test_dictwidget.py

    r5377 r5378  
    493493        assert widget._getRenderedValue() == {u'somekey': u'somevalue'}
    494494
     495    def test_broken_subwidget(self):
     496        self.field = Dict(__name__=u'foo',
     497                          key_type=TextLine(__name__=u'bar'),
     498                          value_type=TextLine(__name__=u'baz'),
     499                          )
     500        request = TestRequest(form={'field.foo.key.0.bar': u'Hello',
     501                                    'field.foo.value.0.baz': u'world!',
     502                                    'field.foo.count': u'1'})
     503        btw = CustomWidgetFactory(BrokenTextWidget)
     504
     505        # Broken key_subwidget...
     506        widget = DictWidget(
     507            self.field, request, key_subwidget=btw)
     508        self.assertRaises(WidgetInputError, widget.getInputValue)
     509        assert widget._error is not None
     510        assert widget._error.errors == 'Intended Exception'
     511
     512        # Broken value_subwidget...
     513        widget = DictWidget(
     514            self.field, request, value_subwidget=btw)
     515        self.assertRaises(WidgetInputError, widget.getInputValue)
     516        assert widget._error is not None
     517        assert widget._error.errors == 'Intended Exception'
     518
     519       
    495520class DictDisplayWidgetTest(
    496521    VerifyResults, DictWidgetTestHelper, unittest.TestCase):
     
    578603        return super(UppercaseDisplayWidget, self).__call__().upper()
    579604
     605class BrokenTextWidget(TextWidget):
     606    """A text widget that tells, that everything is okay even if it is not.
     607    """
     608    def hasValidInput(self):
     609        return True
     610    def getInputValue(self):
     611        """Raise input error intentionally.
     612        """
     613        raise WidgetInputError(
     614            self.context.__name__, self.context.title, 'Intended Exception')
    580615
    581616def setUp(test):
Note: See TracChangeset for help on using the changeset viewer.