Esempio n. 1
0
def test_separator_down():
    message = 'Foo message'
    kwargs = {'choices': ['foo', Separator(), 'bazz']}
    text = KeyInputs.DOWN + KeyInputs.SPACE + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input('checkbox', message, text, **kwargs)
    assert result == ["bazz"]
Esempio n. 2
0
def test_cycle_to_first_choice():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bar", "bazz"]}
    text = KeyInputs.DOWN + KeyInputs.DOWN + KeyInputs.DOWN + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("select", message, text, **kwargs)
    assert result == "foo"
Esempio n. 3
0
def test_select_initial_choice_string():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bazz"], "default": "bazz"}
    text = KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("select", message, text, **kwargs)
    assert result == "bazz"
Esempio n. 4
0
def test_cycle_backwards():
    message = 'Foo message'
    kwargs = {'choices': ['foo', 'bar', 'bazz']}
    text = KeyInputs.UP + KeyInputs.SPACE + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input('checkbox', message, text, **kwargs)
    assert result == ["bazz"]
Esempio n. 5
0
def test_separator_up():
    message = 'Foo message'
    kwargs = {'choices': ['foo', Separator(), 'bazz', Separator("--END--")]}
    text = KeyInputs.UP + KeyInputs.UP + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input('select', message, text, **kwargs)
    assert result == 'foo'
Esempio n. 6
0
def test_separator_up():
    message = "Foo message"
    kwargs = {"choices": ["foo", Separator(), "bazz", Separator("--END--")]}
    text = KeyInputs.UP + KeyInputs.UP + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("select", message, text, **kwargs)
    assert result == "foo"
Esempio n. 7
0
def test_submit_empty():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bar", "bazz"]}
    text = KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("checkbox", message, text, **kwargs)
    assert result == []
Esempio n. 8
0
def test_legacy_name():
    message = 'Foo message'
    kwargs = {'choices': ['foo', 'bar', 'bazz']}
    text = KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input('list', message, text, **kwargs)
    assert result == 'foo'
Esempio n. 9
0
def test_list_random_input():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bazz"]}
    text = "sdf" + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("checkbox", message, text, **kwargs)
    assert result == []
Esempio n. 10
0
def test_checkbox_initial_choice():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bazz"], "initial_choice": "bazz"}
    text = KeyInputs.SPACE + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("checkbox", message, text, **kwargs)
    assert result == ["bazz"]
Esempio n. 11
0
def test_cycle_backwards_using_k():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bar", "bazz"]}
    text = "k" + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("select", message, text, **kwargs)
    assert result == "bazz"
Esempio n. 12
0
def test_select_second_choice_using_j():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bar", "bazz"]}
    text = "j" + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("select", message, text, **kwargs)
    assert result == "bar"
Esempio n. 13
0
def test_separator_shortcuts():
    message = "Foo message"
    kwargs = {"choices": ["foo", Separator(), "bazz"]}
    text = "2" + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("rawselect", message, text, **kwargs)
    assert result == "bazz"
Esempio n. 14
0
def test_select_third_choice():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bar", "bazz"]}
    text = "2" + "3" + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("rawselect", message, text, **kwargs)
    assert result == "bazz"
Esempio n. 15
0
def test_cycle_backwards():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bar", "bazz"]}
    text = KeyInputs.UP + KeyInputs.SPACE + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("checkbox", message, text, **kwargs)
    assert result == ["bazz"]
Esempio n. 16
0
def test_select_third_choice():
    message = 'Foo message'
    kwargs = {'choices': ['foo', 'bar', 'bazz']}
    text = KeyInputs.DOWN + KeyInputs.DOWN + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input('select', message, text, **kwargs)
    assert result == 'bazz'
Esempio n. 17
0
def test_separator_down():
    message = "Foo message"
    kwargs = {"choices": ["foo", Separator(), "bazz"]}
    text = KeyInputs.DOWN + KeyInputs.SPACE + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("checkbox", message, text, **kwargs)
    assert result == ["bazz"]
Esempio n. 18
0
def test_cycle_backwards_using_k():
    message = 'Foo message'
    kwargs = {'choices': ['foo', 'bar', 'bazz']}
    text = "k" + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input('select', message, text, **kwargs)
    assert result == 'bazz'
Esempio n. 19
0
def test_list_random_input():
    message = 'Foo message'
    kwargs = {'choices': ['foo', 'bazz']}
    text = "sdf" + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input('checkbox', message, text, **kwargs)
    assert result == []
Esempio n. 20
0
def test_select_random_input():
    message = 'Foo message'
    kwargs = {'choices': ['foo', 'bazz']}
    text = "some random input" + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input('select', message, text, **kwargs)
    assert result == 'foo'
Esempio n. 21
0
def test_select_first_choice():
    message = 'Foo message'
    kwargs = {'choices': ['foo', 'bar', 'bazz']}
    text = KeyInputs.SPACE + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input('checkbox', message, text, **kwargs)
    assert result == ["foo"]
Esempio n. 22
0
def test_select_random_input():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bazz"]}
    text = "some random input" + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("select", message, text, **kwargs)
    assert result == "foo"
Esempio n. 23
0
def test_submit_empty():
    message = 'Foo message'
    kwargs = {'choices': ['foo', 'bar', 'bazz']}
    text = KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input('checkbox', message, text, **kwargs)
    assert result == []
Esempio n. 24
0
def test_legacy_name():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bar", "bazz"]}
    text = KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("list", message, text, **kwargs)
    assert result == "foo"
Esempio n. 25
0
def test_validate_default_message():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bar", "bazz"], "validate": lambda a: len(a) != 0}
    text = KeyInputs.ENTER + "i" + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("checkbox", message, text, **kwargs)
    assert result == ["foo", "bar", "bazz"]
Esempio n. 26
0
def test_select_shortcuts():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bazz"], "use_shortcuts": True}
    text = "2" + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("select", message, text, **kwargs)
    assert result == "bazz"
Esempio n. 27
0
def test_select_default_has_arrow_keys():
    message = "Foo message"
    kwargs = {"choices": ["foo", "bazz"]}
    text = KeyInputs.DOWN + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("select", message, text, **kwargs)
    assert result == "bazz"
Esempio n. 28
0
def test_select_initial_choice_duplicate():
    message = "Foo message"
    choice = Choice("foo")
    kwargs = {"choices": ["foo", choice, "bazz"], "default": choice}
    text = KeyInputs.DOWN + KeyInputs.ENTER + "\r"

    result, cli = feed_cli_with_input("select", message, text, **kwargs)
    assert result == "bazz"
Esempio n. 29
0
def test_text_validate():
    message = 'What is your name'
    text = "Doe\r"

    result, cli = feed_cli_with_input(
        'text', message, text,
        validate=lambda val: val == 'Doe' or 'is your last name Doe?')
    assert result == 'Doe'
Esempio n. 30
0
def test_separator_up():
    message = 'Foo message'
    kwargs = {'choices': ['foo', Separator(), 'bazz', Separator("--END--")]}
    text = (KeyInputs.UP + KeyInputs.UP + KeyInputs.SPACE + KeyInputs.ENTER +
            "\r")

    result, cli = feed_cli_with_input('checkbox', message, text, **kwargs)
    assert result == ["foo"]