Example #1
0
 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_FAILED,
     )
Example #2
0
 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_SUCCEEDED,
     )
Example #3
0
    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)
Example #4
0
    def test_fail_unless(self):
        unless_result = MagicMock()
        unless_result.return_code = 0

        bundle = MagicMock()
        bundle.node.run.return_value = unless_result

        action = Action(bundle, "action", {'command': "/bin/true", 'unless': "true"})
        self.assertEqual(
            action.get_result(),
            Action.STATUS_SKIPPED,
        )
Example #5
0
    def test_return_code(self):
        run_result = MagicMock()
        run_result.return_code = 1
        run_result.stderr = ""
        run_result.stdout = ""

        bundle = MagicMock()
        bundle.node.run.return_value = run_result

        action = Action(bundle, "action", {'command': "/bin/true"})

        with self.assertRaises(ActionFailure):
            action.run()
Example #6
0
 def test_declined_interactive(self, ask_interactively):
     action = Action(MagicMock(), "action", {'command': "/bin/true"})
     self.assertEqual(
         action.get_result(interactive=True),
         Action.STATUS_SKIPPED,
     )
Example #7
0
 def test_skip_noninteractive(self):
     action = Action(MagicMock(), "action", {'command': "/bin/true", 'interactive': True})
     self.assertEqual(
         action.get_result(interactive=False),
         Action.STATUS_SKIPPED,
     )