예제 #1
0
def test_action_run_failed_with_stderr():
    action = Action()
    with pytest.raises(ActionError) as e:
        action.run('>&2 echo -n oh no && false',
                   shell=True,
                   executable='/bin/bash')
    assert e.value.args[0] == 'oh no'
예제 #2
0
def test_action_run_failed_with_custom_error_and_stderr():
    action = Action()
    with pytest.raises(ActionError) as e:
        action.run('>&2 echo -n oh no && false',
                   shell=True,
                   executable='/bin/bash',
                   fail_error='no cows allowed')
    assert e.value.args[0] == 'no cows allowed: oh no'
예제 #3
0
def test_action_run_capture_stderr():
    action = Action()
    process = action.run('>&2 echo -n hi',
                         shell=True,
                         executable='/bin/bash',
                         stderr=True)
    assert process.returncode == 0
    assert process.stdout is None
    assert process.stderr == 'hi'
예제 #4
0
def test_action_ok():
    action = Action()
    assert action.ok(path='/Users/fots/data') == ActionResponse(
        changed=False, data={'path': '/Users/fots/data'})
예제 #5
0
def test_action_run_capture_stdout():
    action = Action()
    process = action.run(['echo', '-n', 'hi'], stdout=True)
    assert process.returncode == 0
    assert process.stdout == 'hi'
    assert process.stderr == ''
예제 #6
0
def test_action_run_failed_with_custom_error():
    action = Action()
    with pytest.raises(ActionError) as e:
        action.run(['false'], fail_error='no cows allowed')
    assert e.value.args[0] == 'no cows allowed'
예제 #7
0
def test_action_run_failed_not_found():
    action = Action()
    with pytest.raises(ActionError) as e:
        action.run(['falseeeeeey'])
    assert e.value.args[
        0] == "unable to find executable for command ['falseeeeeey']"
예제 #8
0
def test_action_run_failed_ignore():
    action = Action()
    process = action.run(['false'], ignore_fail=True)
    assert process.returncode == 1
    assert process.stdout is None
    assert process.stderr is None
예제 #9
0
def test_action_run_failed():
    action = Action()
    with pytest.raises(ActionError) as e:
        action.run(['false'])
    assert e.value.args[0] == "unable to execute command ['false']"
예제 #10
0
def test_action_run_ok():
    action = Action()
    process = action.run(['echo', '-n', 'hi'])
    assert process.returncode == 0
    assert process.stdout is None
    assert process.stderr == ''
예제 #11
0
def test_action_changed():
    action = Action()
    assert action.changed(path='/Users/fots/data') == ActionResponse(
        changed=True, data={'path': '/Users/fots/data'})