def test_static_text(document, comm): text = StaticText(value='ABC', name='Text:') widget = text.get_root(document, comm=comm) assert isinstance(widget, text._widget_type) assert widget.text == '<b>Text:</b>: ABC' text.value = 'CBA' assert widget.text == '<b>Text:</b>: CBA'
def test_static_text(document, comm): text = StaticText(value='ABC', name='Text:') box = text._get_model(document, comm=comm) assert isinstance(box, WidgetBox) widget = box.children[0] assert isinstance(widget, text._widget_type) assert widget.text == '<b>Text:</b>: ABC' text.value = 'CBA' assert widget.text == '<b>Text:</b>: CBA'
def test_embed_merged_sliders(document, comm): s1 = IntSlider(name='A', start=1, end=10, value=1) t1 = StaticText() s1.param.watch(lambda event: setattr(t1, 'value', event.new), 'value') s2 = IntSlider(name='A', start=1, end=10, value=1) t2 = StaticText() s2.param.watch(lambda event: setattr(t2, 'value', event.new), 'value') panel = Row(s1, s2, t1, t2) with config.set(embed=True): model = panel.get_root(document, comm) state_model = embed_state(panel, model, document) assert len(document.roots) == 2 assert model is document.roots[0] cbs = list(model.select({'type': CustomJS})) assert len(cbs) == 5 ref1, ref2 = model.children[2].ref['id'], model.children[3].ref['id'] state0 = json.loads(state_model.state[0]['content'])['events'] assert state0 == [{ "attr": "text", "kind": "ModelChanged", "model": { "id": ref1 }, "new": "1" }, { "attr": "text", "kind": "ModelChanged", "model": { "id": ref2 }, "new": "1" }] state1 = json.loads(state_model.state[1]['content'])['events'] assert state1 == [{ "attr": "text", "kind": "ModelChanged", "model": { "id": ref1 }, "new": "5" }, { "attr": "text", "kind": "ModelChanged", "model": { "id": ref2 }, "new": "5" }] state2 = json.loads(state_model.state[2]['content'])['events'] assert state2 == [{ "attr": "text", "kind": "ModelChanged", "model": { "id": ref1 }, "new": "9" }, { "attr": "text", "kind": "ModelChanged", "model": { "id": ref2 }, "new": "9" }]