Exemplo n.º 1
0
class TestMultipleSelection:
    def setup(self):
        class FakeProvider(object):
            def get_dropdown_options(self, e, fn, dfn):
                return [('1', 'a'), ('2', 'b')]

        self.widget = PropertyMultipleSelectField(
            options=[('1', 'a'), ('2', 'b')],
            validator=_ListOrIntValidator(),
            item_validator=IntValidator(),
            provider=FakeProvider())

    def test_multiple_selection_single_entry(self):
        if not hasattr(self.widget, 'req'):
            raise SkipTest('Test for Tw2')
        self.widget.req()._validate('1') == [1]

    def test_multiple_selection_invalid_entries(self):
        if not hasattr(self.widget, 'req'):
            raise SkipTest('Test for TW2')
        self.widget.req()._validate(['a', 'b']) == []

    def test_multiple_selection_invalid_entries_display(self):
        if not hasattr(self.widget, 'req'):
            raise SkipTest('Test for TW2')
        res = self.widget.req().display(value=['1', 'b', 'c', 'd', 'e'])
        res.count('selected="selected"') == 1, res
Exemplo n.º 2
0
class TestMultipleSelection:
    def setup(self):
        class FakeProvider(object):
            def get_dropdown_options(self, e, fn, dfn):
                return [('1', 'a'), ('2', 'b')]

        self.widget = PropertyMultipleSelectField(options=[('1', 'a'), ('2', 'b')],
                                                  validator=_ListOrIntValidator(),
                                                  item_validator=IntValidator(),
                                                  provider=FakeProvider())

    def test_multiple_selection_single_entry(self):
        if not hasattr(self.widget, 'req'):
            raise SkipTest('Test for Tw2')
        self.widget.req()._validate('1') == [1]

    def test_multiple_selection_invalid_entries(self):
        if not hasattr(self.widget, 'req'):
            raise SkipTest('Test for TW2')
        self.widget.req()._validate(['a', 'b']) == []

    def test_multiple_selection_invalid_entries_display(self):
        if not hasattr(self.widget, 'req'):
            raise SkipTest('Test for TW2')
        res = self.widget.req().display(value=['1', 'b', 'c', 'd', 'e'])
        res.count('selected="selected"') == 1, res
Exemplo n.º 3
0
    def setup(self):
        class FakeProvider(object):
            def get_dropdown_options(self, e, fn, dfn):
                return [('1', 'a'), ('2', 'b')]

        self.widget = PropertyMultipleSelectField(
            options=[('1', 'a'), ('2', 'b')],
            validator=_ListOrIntValidator(),
            item_validator=IntValidator(),
            provider=FakeProvider())
Exemplo n.º 4
0
class TestMultipleSelection:
    def setup(self):
        self.widget = PropertyMultipleSelectField(options=[('1', 'a'), ('2', 'b')],
                                                  validator=IntValidator())

    def test_multiple_selection_single_entry(self):
        if not hasattr(self.widget, 'req'):
            raise SkipTest('Test for Tw2')
        self.widget.req()._validate('1') == [1]

    def test_multiple_selection_invalid_entries(self):
        if not hasattr(self.widget, 'req'):
            raise SkipTest('Test for TW2')
        self.widget.req()._validate(['a', 'b']) == []
Exemplo n.º 5
0
    def setup(self):
        class FakeProvider(object):
            def get_dropdown_options(self, e, fn, dfn):
                return [('1', 'a'), ('2', 'b')]

        self.widget = PropertyMultipleSelectField(options=[('1', 'a'), ('2', 'b')],
                                                  validator=_ListOrIntValidator(),
                                                  item_validator=IntValidator(),
                                                  provider=FakeProvider())
Exemplo n.º 6
0
 def setup(self):
     self.widget = PropertyMultipleSelectField(options=[('1', 'a'), ('2', 'b')],
                                               validator=IntValidator())