Пример #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"]
Пример #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"
Пример #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"
Пример #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"]
Пример #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'
Пример #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"
Пример #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 == []
Пример #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'
Пример #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 == []
Пример #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"]
Пример #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"
Пример #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"
Пример #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"
Пример #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"
Пример #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"]
Пример #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'
Пример #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"]
Пример #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'
Пример #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 == []
Пример #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'
Пример #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"]
Пример #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"
Пример #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 == []
Пример #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"
Пример #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"]
Пример #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"
Пример #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"
Пример #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"
Пример #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'
Пример #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"]