def test_checkbox(): checkbox = wired.Checkbox(name="Test CheckBox") assert "disabled" in checkbox.attributes_to_watch assert checkbox.html.startswith("<wired-checkbox") assert checkbox.html.endswith("</wired-checkbox>") # When/Then checkbox.disabled = True assert checkbox.attributes_last_change == {"disabled": ""} checkbox.update_html_from_attributes_to_watch() assert "disabled" in checkbox.html # When/Then checkbox.disabled = False assert checkbox.attributes_last_change == {"disabled": None} checkbox.update_html_from_attributes_to_watch() assert "disabled" not in checkbox.html
def test_checkbox_constructor_checked(): checkbox = wired.Checkbox(value=True) assert checkbox.properties_last_change == {"checked": True}
def test_checkbox_name(): checkbox = wired.Checkbox() checkbox.name = "Testing" assert ">Testing<" in checkbox.html
def test_wired_view(): # pylint: disable=too-many-locals """Returns a column with all the wired elements""" show_html = False def section(component, message=None, show_html=show_html): title = "## " + str(type(component)).split(".")[4][:-2] parameterset = set(component._child_parameters()) # pylint: disable=protected-access if show_html: parameterset.add("html") for parameter in component.parameters_to_watch: parameterset.add(parameter) parameters = list(parameterset) if message: return ( pn.pane.Markdown(title), pn.pane.Markdown(message), component, pn.Param(component, parameters=parameters), pn.layout.Divider(), ) return ( pn.pane.Markdown(title), component, pn.Param(component, parameters=parameters), pn.layout.Divider(), ) button = wired.Button() check_box = wired.Checkbox() date_picker = wired.DatePicker() # dialog = wired.Dialog(text="Lorum Ipsum. Panel is awesome!") divider = wired.Divider() fab = wired.Fab() float_slider = wired.FloatSlider() icon_button = wired.IconButton() int_slider = wired.IntSlider() image = wired.Image( object="https://www.gstatic.com/webp/gallery/1.sm.jpg", height=200, width=300 ) link = wired.Link(href="https://panel.holoviz.org/", text="HoloViz", target="_blank") # literal_input = wired.LiteralInput(default={"a": 1, "b": "hello app world"}) progress = wired.Progress(value=50) progress_spinner = wired.ProgressSpinner() radio_button = wired.RadioButton() search_input = wired.SearchInput() select = wired.Select( html="""<wired-combo id="colorCombo" selected="red" role="combobox" \ aria-haspopup="listbox" tabindex="0" class="wired-rendered" aria-expanded="false">\ <wired-item value="red" aria-selected="true" role="option" class="wired-rendered">Red</wired-item>\ <wired-item value="green" role="option" class="wired-rendered">Green</wired-item>\ <wired-item value="blue" role="option" class="wired-rendered">Blue</wired-item></wired-combo>""" ) text_area = wired.TextAreaInput() text_input = wired.TextInput() toggle = wired.Toggle() video = wired.Video( autoplay=True, loop=True, object=( "https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4" ), ) section(select) return pn.Column( *section(button), *section(check_box), *section(date_picker), # *section(dialog), *section(divider), *section(fab), *section(float_slider, message="**Not fully implemented!**"), *section(icon_button), *section(image), *section(int_slider, message="**Not fully implemented!**"), *section( link, """Normally you would just use the `<wired-link>` tag directly in your html \ or markdown text""", ), # *section(literal_input), *section(progress), *section(radio_button), *section(search_input, message="**Not fully implemented!**"), *section(select, message="**Not fully implemented!**"), *section(progress_spinner), *section(text_area, message="**Not fully implemented!**"), *section(text_input, message="**Not fully implemented!**"), *section(toggle), *section(video), name="Elements", )