示例#1
0
def test_run_script_proper_output(buffer_connection, command_output_lines):
    command_output, expected_result = command_output_lines
    buffer_connection.remote_inject_response([command_output])
    cmd = RunScript(connection=buffer_connection.moler_connection,
                    script_command="./myScript.sh",
                    success_regex=["Line 1", "Line 2"])
    result = cmd()
    assert result == expected_result
示例#2
0
def test_run_script_raise_exception(buffer_connection,
                                    command_output_and_expected_result):
    command_output, expected_result = command_output_and_expected_result
    buffer_connection.remote_inject_response([command_output])
    cmd = RunScript(connection=buffer_connection.moler_connection,
                    script_command="./myScript.sh")
    with pytest.raises(CommandFailure):
        cmd()
示例#3
0
def test_run_script_not_raise_exception(buffer_connection,
                                        command_output_and_expected_result):
    command_output, expected_result = command_output_and_expected_result
    buffer_connection.remote_inject_response([command_output])
    cmd = RunScript(connection=buffer_connection.moler_connection,
                    script_command="./myScript.sh",
                    error_regex=None)
    result = cmd()
    assert not result
示例#4
0
def test_run_script_raise_exception_wrong_output(buffer_connection,
                                                 command_output_lines):
    command_output, expected_result = command_output_lines
    buffer_connection.remote_inject_response([command_output])
    cmd = RunScript(connection=buffer_connection.moler_connection,
                    script_command="./myScript.sh",
                    success_regex="Line 3",
                    error_regex=None)
    with pytest.raises(CommandFailure):
        cmd()
示例#5
0
def test_run_script_cmd_returns_proper_command_string(buffer_connection):
    cmd = RunScript(connection=buffer_connection.moler_connection,
                    script_command="./myScript.sh")
    assert "./myScript.sh" == cmd.command_string