Пример #1
0
def inp_addtwo():
    vals1 = [1, 2, 3]
    vals2 = [1, 2, 3]
    sel1 = Select(name="x", options=vals1)
    sel2 = Select(name="y", options=vals2)
    btn = Button(description="Submit", action=webapp.get_action("out_addtwo"))
    return [sel1, sel2, btn]
Пример #2
0
def test_select_with_selected():
    partial = Select(options=["1", "2"], selected="2")
    expected = (
        f'<select class="{partial._class}"><option value=""></option>'
        '<option>1</option><option selected="selected">2</option></select>')
    test_input = partial.render()
    assert clear_string(test_input) == clear_string(expected)
Пример #3
0
def test_connected_dropdowns_with_filter():
    data = {"col1": ["Bob", "Bob", "Cole"], "col2": [1, 2, 3]}
    partial = ConnectedDropdowns(data=data, filters={"col1": "Cole"})
    select_1 = Select(options=["Bob", "Cole"], name="col1", selected="Cole")
    select_2 = Select(options=[3], name="col2")
    expected = select_1.render() + select_2.render()
    test_input = partial.render()
    assert clear_string(test_input) == clear_string(expected)
Пример #4
0
def test_connected_dropdowns_no_filter():
    data = {"col1": ["Bob", "Bob"], "col2": [1, 2]}
    partial = ConnectedDropdowns(data=data)
    select_1 = Select(options=["Bob"], name="col1")
    select_2 = Select(options=[1, 2], name="col2")
    expected = select_1.render() + select_2.render()
    test_input = partial.render()
    assert clear_string(test_input) == clear_string(expected)
Пример #5
0
def inp_cascading_selects(source: str = "",
                          schema: str = "",
                          table: str = "",
                          column: str = "",
                          independent: str = ""):
    data = mockapis.sources
    filters = {
        "source": source,
        "schema": schema,
        "table": table,
        "column": column
    }
    action = webapp.get_action("inp_cascading_selects")

    sel1 = ConnectedDropdowns(data=data, filters=filters, action=action)

    independents = ["movies", "books", "etc"]
    sel3 = Select(name="independent",
                  options=independents,
                  selected=independent)
    btn = Button(description="Submit",
                 action=webapp.get_action("out_cascading_selects_1"))
    return [sel1, sel3, btn]
Пример #6
0
def test_select_empty():
    partial = Select(options=[])
    expected = f'<select class="{partial._class}"><option value=""></option></select>'
    test_input = partial.render()
    assert clear_string(test_input) == clear_string(expected)