Exemple #1
0
def test_toggle(document, comm):
    toggle = Toggle(name='Toggle', value=True)

    widget = toggle._get_root(document, comm=comm)

    assert isinstance(widget, toggle._widget_type)
    assert widget.active == True
    assert widget.label == 'Toggle'

    widget.active = False
    toggle._comm_change({'active': widget.active})
    assert toggle.value == False

    toggle.value = True
    assert widget.active == True
Exemple #2
0
def test_toggle(document, comm):
    toggle = Toggle(name='Toggle', active=True)

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

    assert isinstance(box, WidgetBox)

    widget = box.children[0]
    assert isinstance(widget, toggle._widget_type)
    assert widget.active == True
    assert widget.label == 'Toggle'

    widget.active = False
    toggle._comm_change({'active': widget.active})
    assert toggle.active == False

    toggle.active = True
    assert widget.active == True