def test_widget_base_custom_css(self): from plone.app.z3cform.widget import BaseWidget from plone.app.widgets.base import InputWidget widget = BaseWidget(self.request) widget.field = self.field widget.pattern = 'example' widget.klass = 'very-custom-class' widget._base = InputWidget self.assertEqual( '<input class="pat-example very-custom-class" type="text"/>', widget.render())
def test_widget_pattern_notimplemented(self): from plone.app.widgets.utils import NotImplemented widget = BaseWidget(self.request) widget.field = self.field self.assertRaises(NotImplemented, widget._base_args) widget.pattern = 'example' self.assertEqual({ 'pattern': 'example', 'pattern_options': {} }, widget._base_args())
def test_widget_base_notimplemented(self): from plone.app.z3cform.widget import BaseWidget from plone.app.widgets.base import InputWidget from plone.app.widgets.utils import NotImplemented widget = BaseWidget(self.request) widget.field = self.field widget.pattern = 'example' self.assertRaises(NotImplemented, widget.render) widget._base = InputWidget self.assertEqual('<input class="pat-example" type="text"/>', widget.render())
def test_widget_base_notimplemented(self): from plone.app.z3cform.widget import BaseWidget from plone.app.widgets.base import InputWidget from plone.app.widgets.utils import NotImplemented widget = BaseWidget(self.request) widget.field = self.field widget.pattern = 'example' self.assertRaises( NotImplemented, widget.render) widget._base = InputWidget self.assertEqual( '<input class="pat-example" type="text"/>', widget.render())
def test_widget_pattern_notimplemented(self): from plone.app.widgets.utils import NotImplemented widget = BaseWidget(self.request) widget.field = self.field self.assertRaises( NotImplemented, widget._base_args) widget.pattern = 'example' self.assertEqual( { 'pattern': 'example', 'pattern_options': {} }, widget._base_args())
def test_widget_base_pattern_options_with_functions(self): from plone.app.z3cform.widget import BaseWidget from plone.app.widgets.base import InputWidget widget = BaseWidget(self.request) widget.context = 'testcontext' widget.field = self.field widget.pattern = 'example' widget._base = InputWidget widget.pattern_options = { 'subdict': { 'subsubnormal': 789, 'subsublist': [7, 8, 9, lambda x: x], 'subsubtuple': (7, 8, 9, lambda x: x), } } self.assertEqual( '<input class="pat-example" type="text" ' 'data-pat-example="{"subdict": ' '{"subsubtuple": [7, 8, 9, "testcontext"], ' '"subsublist": [7, 8, 9, "testcontext"], ' '"subsubnormal": 789}}"/>', widget.render())