Esempio n. 1
0
    def test_widget(self):
        from plone.app.widgets.at import SelectWidget
        widget = SelectWidget()
        self.assertEqual(
            {
                'multiple': False,
                'name': 'fieldname',
                'pattern_options': {'separator': ';'},
                'pattern': 'select2',
                'value': (),
                'items': [
                    ('one', 'one'),
                    ('two', 'two'),
                    ('three', 'three')
                ]
            },
            widget._base_args(self.context, self.field, self.request),
        )

        widget.multiple = True
        self.assertEqual(
            {
                'multiple': True,
                'name': 'fieldname',
                'pattern_options': {'separator': ';'},
                'pattern': 'select2',
                'value': (),
                'items': [
                    ('one', 'one'),
                    ('two', 'two'),
                    ('three', 'three')
                ]
            },
            widget._base_args(self.context, self.field, self.request),
        )

        self.field.getAccessor.return_value = lambda: u'one'
        self.assertEqual(
            {
                'multiple': True,
                'name': 'fieldname',
                'pattern_options': {'separator': ';'},
                'pattern': 'select2',
                'value': (u'one'),
                'items': [
                    ('one', 'one'),
                    ('two', 'two'),
                    ('three', 'three')
                ]
            },
            widget._base_args(self.context, self.field, self.request),
        )
Esempio n. 2
0
    def test_widget(self):
        from plone.app.widgets.at import SelectWidget
        widget = SelectWidget()
        self.assertEqual(
            {
                'multiple': False,
                'name': 'fieldname',
                'pattern_options': {
                    'separator': ';'
                },
                'pattern': 'select2',
                'value': (),
                'items': [('one', 'one'), ('two', 'two'), ('three', 'three')]
            },
            widget._base_args(self.context, self.field, self.request),
        )

        widget.multiple = True
        self.assertEqual(
            {
                'multiple': True,
                'name': 'fieldname',
                'pattern_options': {
                    'separator': ';'
                },
                'pattern': 'select2',
                'value': (),
                'items': [('one', 'one'), ('two', 'two'), ('three', 'three')]
            },
            widget._base_args(self.context, self.field, self.request),
        )

        self.field.getAccessor.return_value = lambda: u'one'
        self.assertEqual(
            {
                'multiple': True,
                'name': 'fieldname',
                'pattern_options': {
                    'separator': ';'
                },
                'pattern': 'select2',
                'value': (u'one'),
                'items': [('one', 'one'), ('two', 'two'), ('three', 'three')]
            },
            widget._base_args(self.context, self.field, self.request),
        )
Esempio n. 3
0
 def test_widget_orderable(self):
     from plone.app.widgets.at import SelectWidget
     widget = SelectWidget()
     widget.multiple = True
     widget.orderable = True
     self.assertEqual(
         {
             'multiple': True,
             'name': 'fieldname',
             'pattern_options': {
                 'orderable': True,
                 'separator': ';'
             },
             'pattern': 'select2',
             'value': (),
             'items': [('one', 'one'), ('two', 'two'), ('three', 'three')]
         },
         widget._base_args(self.context, self.field, self.request),
     )
Esempio n. 4
0
 def test_widget_orderable(self):
     from plone.app.widgets.at import SelectWidget
     widget = SelectWidget()
     widget.multiple = True
     widget.orderable = True
     self.assertEqual(
         {
             'multiple': True,
             'name': 'fieldname',
             'pattern_options': {'orderable': True, 'separator': ';'},
             'pattern': 'select2',
             'value': (),
             'items': [
                 ('one', 'one'),
                 ('two', 'two'),
                 ('three', 'three')
             ]
         },
         widget._base_args(self.context, self.field, self.request),
     )