def test_plotly_tabs(document, comm): trace = go.Scatter(x=[0, 1], y=[2, 3]) pane1 = Plotly(dict(data=[trace], layout={'autosize': True})) pane2 = Plotly(dict(data=[trace], layout={'autosize': True})) tabs = Tabs(pane1, pane2) root = tabs.get_root(document, comm) model1 = pane1._models[root.id][0] model2 = pane2._models[root.id][0] cb1, cb2 = root.js_property_callbacks['change:active'] if cb1.args['model'] is model2: cb1, cb2 = cb2, cb1 assert model1.visible assert cb1.args['model'] is model1 assert cb1.args['i'] == 0 assert not model2.visible assert cb2.args['model'] is model2 assert cb2.args['i'] == 1 tabs.insert(0, 'Blah') assert cb1.args['i'] == 1 assert cb2.args['i'] == 2
def test_tabs_insert(document, comm): div1 = Div() div2 = Div() tabs = Tabs(div1, div2) model = tabs._get_model(document, comm=comm) div3 = Div() tabs.insert(1, div3) tab1, tab2, tab3 = model.tabs assert get_div(tab1.child.children[0]) is div1 assert get_div(tab2.child.children[0]) is div3 assert get_div(tab3.child.children[0]) is div2