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'
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'
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'
def test_action_ok(): action = Action() assert action.ok(path='/Users/fots/data') == ActionResponse( changed=False, data={'path': '/Users/fots/data'})
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 == ''
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'
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']"
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
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']"
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 == ''
def test_action_changed(): action = Action() assert action.changed(path='/Users/fots/data') == ActionResponse( changed=True, data={'path': '/Users/fots/data'})