Beispiel #1
0
def test_exec_cmd_fail_hard_fail(mock_subp):
    # GIVEN a command will exit with a non-zero return code
    cmd_args = ["foobar"]
    stdout = "This is output"
    stderr = "This is error"
    job_mock = _get_job_mock(1, stdout, stderr)
    mock_subp.return_value = job_mock

    # WHEN the command is executed
    # THEN a Fatal is raised
    with pytest.raises(ops_utils.Fatal):
        ops_utils.exec_cmd_fail_hard(cmd_args)
Beispiel #2
0
def test_exec_cmd_fail_hard_fail(mock_subp):
    # GIVEN a command will exit with a non-zero return code
    cmd_args = ["foobar"]
    stdout = "This is output"
    stderr = "This is error"
    job_mock = _get_job_mock(1, stdout, stderr)
    mock_subp.return_value = job_mock

    # WHEN the command is executed
    # THEN a Fatal is raised
    with pytest.raises(ops_utils.Fatal):
        ops_utils.exec_cmd_fail_hard(cmd_args)
Beispiel #3
0
def test_exec_cmd_fail_hard_success(mock_subp):
    # GIVEN a command will exit with a non-zero return code
    cmd_args = ["foobar"]
    stdout = "This is output"
    stderr = "This is error"
    job_mock = _get_job_mock(0, stdout, stderr)
    mock_subp.return_value = job_mock

    # WHEN the command is executed
    exit_status, out, err = ops_utils.exec_cmd_fail_hard(cmd_args)

    # THEN we receive the expected results of the command
    assert exit_status == 0
    assert out == stdout
    assert err == stderr
Beispiel #4
0
def test_exec_cmd_fail_hard_success(mock_subp):
    # GIVEN a command will exit with a non-zero return code
    cmd_args = ["foobar"]
    stdout = "This is output"
    stderr = "This is error"
    job_mock = _get_job_mock(0, stdout, stderr)
    mock_subp.return_value = job_mock

    # WHEN the command is executed
    exit_status, out, err = ops_utils.exec_cmd_fail_hard(cmd_args)

    # THEN we receive the expected results of the command
    assert exit_status == 0
    assert out == stdout
    assert err == stderr