示例#1
0
 def test_base(self):
     from plone.app.widgets.dx import BaseWidget
     request = TestRequest(environ={'HTTP_ACCEPT_LANGUAGE': 'en'})
     widget = BaseWidget(request)
     widget.name = 'example'
     self.assertEqual(
         widget._widget_args(),
         {
             'name': 'example',
             'pattern': None,
             'pattern_options': {},
         },
     )
示例#2
0
    def test_widget_pattern_notimplemented(self):
        from plone.app.widgets.dx import BaseWidget
        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())
示例#3
0
    def test_widget_base_notimplemented(self):
        from plone.app.widgets.dx 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())
示例#4
0
    def test_widget_pattern_notimplemented(self):
        from plone.app.widgets.dx import BaseWidget
        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())
示例#5
0
    def test_widget_base_notimplemented(self):
        from plone.app.widgets.dx 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())