Пример #1
0
def test_canonical_value_in_cascading_dropdown(
    choices,
    default_value,
    expected_canonical,
):
    assert vs.CascadingDropdown(
        choices=choices).canonical_value() == expected_canonical
Пример #2
0
def test_default_value_in_cascading_dropdown(
    choices,
    default_value,
    expected_default,
):
    assert vs.CascadingDropdown(
        choices=choices).default_value() == expected_default
Пример #3
0
def test_transform_value_in_cascading_dropdown():
    valuespec = vs.CascadingDropdown(choices=[
        ("a", "Title a", vs.TextInput()),
        ("b", "Title b",
         vs.Transform(
             vs.TextInput(),
             forth=lambda x: x if x == "lala" else x.upper(),
             back=lambda x: x + "aaa",
         )),
    ])

    assert valuespec.transform_value(("a", "abc")) == ("a", "abc")
    assert valuespec.transform_value(("b", "lala")) == ("b", "lalaaaa")
    assert valuespec.transform_value(("b", "AAA")) == ("b", "AAAaaa")