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"]
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"
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"
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"]
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'
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"
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 == []
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'
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 == []
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"]
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"
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"
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"
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"
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"]
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'
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"]
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'
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 == []
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'
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"]
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"
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 == []
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"
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"]
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"
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"
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"
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'
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"]