예제 #1
0
def test_toggle_group_check(document, comm):

    for widget_type in ToggleGroup._widgets_type:
        select = ToggleGroup(options=OrderedDict([('A', 'A'), ('1', 1),
                                                  ('C', object)]),
                             value=[1, object],
                             name='CheckButtonGroup',
                             widget_type=widget_type,
                             behavior='check')

        widget = select.get_root(document, comm=comm)

        assert isinstance(widget, select._widget_type)
        assert widget.active == [1, 2]
        assert widget.labels == ['A', '1', 'C']

        widget.active = [2]
        select._process_events({'active': [2]})
        assert select.value == [object]

        widget.active = [0, 2]
        select._process_events({'active': [0, 2]})
        assert select.value == ['A', object]

        select.value = [object, 'A']
        assert widget.active == [2, 0]

        widget.active = []
        select._process_events({'active': []})
        assert select.value == []

        select.value = ["A", "B"]
        select.options = ["B", "C"]
        select.options = ["A", "B"]
        assert widget.labels[widget.active[0]] == "B"
예제 #2
0
def test_toggle_group_radio(document, comm):

    for widget_type in ToggleGroup._widgets_type:
        select = ToggleGroup(options=OrderedDict([('A', 'A'), ('1', 1),
                                                  ('C', object)]),
                             value=1,
                             name='RadioButtonGroup',
                             widget_type=widget_type,
                             behavior='radio')

        box = select._get_model(document, comm=comm)

        assert isinstance(box, WidgetBox)

        widget = box.children[0]
        assert isinstance(widget, select._widget_type)
        assert widget.active == 1
        assert widget.labels == ['A', '1', 'C']

        widget.active = 2
        select._comm_change({'active': 2})
        assert select.value == object

        select.value = 'A'
        assert widget.active == 0
예제 #3
0
def test_toggle_group_check(document, comm):

    for widget_type in ToggleGroup._widgets_type:
        select = ToggleGroup(options=OrderedDict([('A', 'A'), ('1', 1),
                                                  ('C', object)]),
                             value=[1, object],
                             name='CheckButtonGroup',
                             widget_type=widget_type,
                             behavior='check')

        box = select._get_model(document, comm=comm)

        assert isinstance(box, WidgetBox)

        widget = box.children[0]
        assert isinstance(widget, select._widget_type)
        assert widget.active == [1, 2]
        assert widget.labels == ['A', '1', 'C']

        widget.active = [2]
        select._comm_change({'active': [2]})
        assert select.value == [object]

        widget.active = [0, 2]
        select._comm_change({'active': [0, 2]})
        assert select.value == ['A', object]

        select.value = [object, 'A']
        assert widget.active == [2, 0]

        widget.active = []
        select._comm_change({'active': []})
        assert select.value == []
예제 #4
0
파일: test_select.py 프로젝트: yuttie/panel
def test_toggle_group_radio(document, comm):

    for widget_type in ToggleGroup._widgets_type:
        select = ToggleGroup(options=OrderedDict([('A', 'A'), ('1', 1),
                                                  ('C', object)]),
                             value=1,
                             name='RadioButtonGroup',
                             widget_type=widget_type,
                             behavior='radio')

        widget = select.get_root(document, comm=comm)

        assert isinstance(widget, select._widget_type)
        assert widget.active == 1
        assert widget.labels == ['A', '1', 'C']

        widget.active = 2
        select._process_events({'active': 2})
        assert select.value == object

        select.value = 'A'
        assert widget.active == 0