Beispiel #1
0
 def test_process_form(self):
     from plone.app.widgets.at import SelectWidget
     widget = SelectWidget()
     form = {'fieldname': 'aaa.bbb.ccc'}
     self.assertEquals('aaa.bbb.ccc',
                       widget.process_form(self.context,
                                           self.field, form)[0])
     widget.multiple = True
     widget.separator = "."
     self.assertEquals(['aaa', 'bbb', 'ccc'],
                       widget.process_form(self.context,
                                           self.field, form)[0])
Beispiel #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),
        )
Beispiel #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),
     )
Beispiel #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),
     )
Beispiel #5
0
 def test_process_form(self):
     from plone.app.widgets.at import SelectWidget
     widget = SelectWidget()
     form = {'fieldname': 'aaa.bbb.ccc'}
     self.assertEquals(
         'aaa.bbb.ccc',
         widget.process_form(self.context, self.field, form)[0])
     widget.multiple = True
     widget.separator = "."
     self.assertEquals(['aaa', 'bbb', 'ccc'],
                       widget.process_form(self.context, self.field,
                                           form)[0])
Beispiel #6
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),
        )