def test_stdout(self): run_result = MagicMock() run_result.return_code = 0 run_result.stderr = "" run_result.stdout = "47" bundle = MagicMock() bundle.node.run.return_value = run_result action = Action(bundle, "action", {"command": "/bin/true", "expected_stdout": "48"}) with self.assertRaises(ActionFailure): action.run()
def test_ok(self): run_result = MagicMock() run_result.return_code = 0 run_result.stderr = "" run_result.stdout = "" bundle = MagicMock() bundle.node.run.return_value = run_result action = Action(bundle, "action", {"command": "/bin/true"}) self.assertEqual(action.run(), run_result)
def test_fail(self): action = Action(MagicMock(), "action", {"command": "/bin/false"}) action.run = MagicMock(side_effect=ActionFailure) self.assertEqual(action.get_result(interactive=False), Action.STATUS_ACTION_FAILED)
def test_ok(self): action = Action(MagicMock(), "action", {"command": "/bin/true"}) action.run = MagicMock(return_value=None) self.assertEqual(action.get_result(interactive=False), Action.STATUS_ACTION_OK)