Beispiel #1
0
def test_guides(mocked_input, input, guide, expected, repl: Riposte):
    mocked_input.return_value = "foobar " + input

    @repl.command("foobar")
    def handler_function(x: guide):
        assert x == expected

    repl._process()
Beispiel #2
0
def test_process_no_input(mocked_input, repl: Riposte):
    repl._split_inline_commands = mock.MagicMock()
    repl._parse_line = mock.Mock()
    repl._get_command = mock.Mock()

    repl._process()

    repl._split_inline_commands.assert_not_called()
    repl._parse_line.assert_not_called()
    repl._get_command.assert_not_called()
Beispiel #3
0
def test_process_multi_line(mocked_input, repl: Riposte):
    repl._get_command = mock.Mock()

    repl._process()

    assert repl._get_command.call_args_list == [
        mock.call("foo"),
        mock.call("scoo"),
    ]

    assert repl._get_command.return_value.execute.call_args_list == [
        mock.call("bar"),
        mock.call("bee"),
    ]
Beispiel #4
0
def test_banner_alternative_stream(mocked_print, repl: Riposte):
    repl.banner = "foobar"
    repl._process = mock.Mock(side_effect=StopIteration)
    repl._parse_args = mock.Mock(return_value=True)

    repl.run()

    mocked_print.assert_not_called()
Beispiel #5
0
def test_banner(mocked_print, repl: Riposte):
    repl.banner = "foobar"
    repl._process = mock.Mock(side_effect=StopIteration)
    repl._parse_args = mock.Mock(return_value=False)

    repl.run()

    mocked_print.assert_called_once_with(repl.banner)
Beispiel #6
0
def test_banner_alternative_stream(mocked_print, repl: Riposte):
    repl.banner = "foobar"
    repl.print_banner = False
    repl._process = mock.Mock(side_effect=StopIteration)
    repl.parse_cli_arguments = mock.Mock()

    repl.run()

    mocked_print.assert_not_called()
Beispiel #7
0
def test_banner(mocked_print, repl: Riposte):
    repl.banner = "foobar"
    repl.print_banner = True
    repl._process = mock.Mock(side_effect=StopIteration)
    repl.parse_cli_arguments = mock.Mock()

    repl.run()

    mocked_print.assert_called_once_with(repl.banner)
Beispiel #8
0
def test_process(mocked_input, repl: Riposte, foo_command: Command):
    repl._process()
    foo_command._func.assert_called_once_with("bar")