diff options
| author | Dmitry Tantsur <dtantsur@protonmail.com> | 2021-10-27 14:24:00 +0200 |
|---|---|---|
| committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2021-10-27 14:24:00 +0200 |
| commit | b360214cf222dd91fda214dac419789e16a79bfe (patch) | |
| tree | d567dc446dabfbd98dc2cf9fa1353b19d10e99ed /ironic_python_agent/tests/unit | |
| parent | c824dda7a506d38032831fcd20063a833445d0a3 (diff) | |
| download | ironic-python-agent-b360214cf222dd91fda214dac419789e16a79bfe.tar.gz | |
Stop requiring mocking of utils.execute if ironic-lib execute is mocked
Based on unit tests, this was done intentionally, but I don't see
reasons for that. It makes refactoring much harder, because sometimes
you need to mock both execute functions and test them separately.
In the end, utils.execute should be removed.
Change-Id: I5a9c694ebe626c54f219d4870eab0a592777518d
Diffstat (limited to 'ironic_python_agent/tests/unit')
| -rw-r--r-- | ironic_python_agent/tests/unit/base.py | 3 | ||||
| -rw-r--r-- | ironic_python_agent/tests/unit/test_base.py | 15 |
2 files changed, 1 insertions, 17 deletions
diff --git a/ironic_python_agent/tests/unit/base.py b/ironic_python_agent/tests/unit/base.py index 7d14821f..09019e08 100644 --- a/ironic_python_agent/tests/unit/base.py +++ b/ironic_python_agent/tests/unit/base.py @@ -25,7 +25,6 @@ from oslotest import base as test_base from ironic_python_agent.extensions import base as ext_base from ironic_python_agent import hardware -from ironic_python_agent import utils CONF = cfg.CONF @@ -58,7 +57,7 @@ class IronicAgentTest(test_base.BaseTestCase): self.patch(subprocess, 'call', do_not_call) self.patch(subprocess, 'check_call', do_not_call) self.patch(subprocess, 'check_output', do_not_call) - self.patch(utils, 'execute', do_not_call) + # ironic_python_agent.utils.execute is an alias of ironic_lib one ext_base._EXT_MANAGER = None hardware._CACHED_HW_INFO = None diff --git a/ironic_python_agent/tests/unit/test_base.py b/ironic_python_agent/tests/unit/test_base.py index 37bcac3a..3b182ca0 100644 --- a/ironic_python_agent/tests/unit/test_base.py +++ b/ironic_python_agent/tests/unit/test_base.py @@ -50,21 +50,6 @@ class BlockExecuteTestCase(ironic_agent_base.IronicAgentTest): utils.execute("echo") self.assertEqual(2, mock_exec.call_count) - @mock.patch.object(ironic_lib.utils, "execute", autospec=True) - def test_exception_raised_for_execute_parent_mocked(self, mock_exec): - # Make sure that even if we mock the parent execute function, that we - # still get an exception for a child. So in this case utils.execute() - # calls ironic_lib.utils.execute(). Make sure an exception is raised - # even though we mocked ironic_lib.utils.execute() - exc = self.assertRaises(Exception, utils.execute, "ls") # noqa - # Have to use 'noqa' as we are raising plain Exception and we will get - # H202 error in 'pep8' check. - - self.assertEqual( - "Don't call ironic_lib.utils.execute() / " - "processutils.execute() or similar functions in tests!", - "%s" % exc) - class DontBlockExecuteTestCase(ironic_agent_base.IronicAgentTest): """Ensure we can turn off blocking access to 'execute' type functions""" |
