summaryrefslogtreecommitdiff
path: root/ironic_python_agent/tests/unit/test_utils.py
diff options
context:
space:
mode:
authorJohn L. Villalovos <john.l.villalovos@intel.com>2017-05-17 11:00:38 -0700
committerJohn L. Villalovos <john.l.villalovos@intel.com>2017-10-23 08:44:23 -0700
commitef838dd6bbb8d3c830a69ff2bf6a21b90b9adfaf (patch)
treeb14b5c68c5068df3710a67cca00f0650f1a301dc /ironic_python_agent/tests/unit/test_utils.py
parent265a072b7297b1516eb0db7f9eb821518b68a725 (diff)
downloadironic-python-agent-ef838dd6bbb8d3c830a69ff2bf6a21b90b9adfaf.tar.gz
Improve the catching of calls to 'execute' related functions
Improve the catching of calls to 'execute' related functions in unit tests. Before we only caught calls to utils.execute(). Now we catch calls to: ironic_lib.utils.execute() processutils.execute() subprocess.call() subprocess.check_call() subprocess.check_output() utils.execute() Change-Id: If4720ebed00f15c2a19cb8badbe4dc3c808eeece
Diffstat (limited to 'ironic_python_agent/tests/unit/test_utils.py')
-rw-r--r--ironic_python_agent/tests/unit/test_utils.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/ironic_python_agent/tests/unit/test_utils.py b/ironic_python_agent/tests/unit/test_utils.py
index 31c9988b..8fe8ee53 100644
--- a/ironic_python_agent/tests/unit/test_utils.py
+++ b/ironic_python_agent/tests/unit/test_utils.py
@@ -26,7 +26,6 @@ from ironic_lib import utils as ironic_utils
import mock
from oslo_concurrency import processutils
from oslo_serialization import base64
-from oslotest import base as test_base
import six
import testtools
@@ -35,12 +34,13 @@ from ironic_python_agent.tests.unit import base as ironic_agent_base
from ironic_python_agent import utils
-# Normally we'd use the IronicAgentTest base class which mocks out
-# any use of utils.execute() to prevent accidental processes. However
-# this test is checking the upcall to ironic_lib's execute(), so that
-# is mocked out instead.
-class ExecuteTestCase(test_base.BaseTestCase):
+class ExecuteTestCase(ironic_agent_base.IronicAgentTest):
+ # This test case does call utils.execute(), so don't block access to the
+ # execute calls.
+ block_execute = False
+ # We do mock out the call to ironic_utils.execute() so we don't actually
+ # 'execute' anything, as utils.execute() calls ironic_utils.execute()
@mock.patch.object(ironic_utils, 'execute', autospec=True)
def test_execute(self, mock_execute):
utils.execute('/usr/bin/env', 'false', check_exit_code=False)