diff options
author | Vanou Ishii <ishii.vanou@fujitsu.com> | 2022-08-05 16:58:32 +0900 |
---|---|---|
committer | Vanou Ishii <ishii.vanou@fujitsu.com> | 2022-08-09 15:35:52 +0900 |
commit | 3b28d0984d5eb82320c632dd5840cebf6d0762ad (patch) | |
tree | 367672f6dffedfd201df7993971c9e6ca6bd39b8 /ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py | |
parent | 45c9c3029f5363b6e24e578648c09213a7338db1 (diff) | |
download | ironic-3b28d0984d5eb82320c632dd5840cebf6d0762ad.tar.gz |
Modify test code to avoid CONF modification affection
Few unit tests change attribute of CONF variable via Python
assignment. This changes attribute of CONF, which is instance
of XxxOpt class defined in oslo_config, to Python literal value.
This affects result of another unit test.
To avoid this, we should change attribute of CONF variable with
set_override method.
Change-Id: I4bd8b1b4ea974834f1149fcaa79de85d24f5f7d1
Story: 2010214
Task: 45956
Depends-On: https://review.opendev.org/c/openstack/ironic/+/852253
Diffstat (limited to 'ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py')
-rw-r--r-- | ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py b/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py index e2c6e75b2..61bc23e48 100644 --- a/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py +++ b/ironic/tests/unit/drivers/modules/redfish/test_firmware_utils.py @@ -262,9 +262,9 @@ class FirmwareUtilsTestCase(base.TestCase): @mock.patch.object(os, 'chmod', autospec=True) def test_stage_http(self, mock_chmod, mock_link, mock_copyfile, mock_makedirs): - CONF.deploy.http_url = 'http://10.0.0.2' - CONF.deploy.external_http_url = None - CONF.deploy.http_root = '/httproot' + CONF.set_override('http_url', 'http://10.0.0.2', 'deploy') + CONF.set_override('external_http_url', None, 'deploy') + CONF.set_override('http_root', '/httproot', 'deploy') node = mock.Mock(uuid='55cdaba0-1123-4622-8b37-bb52dd6285d3') staged_url, need_cleanup = firmware_utils.stage( @@ -291,9 +291,9 @@ class FirmwareUtilsTestCase(base.TestCase): @mock.patch.object(os, 'chmod', autospec=True) def test_stage_http_copyfile(self, mock_chmod, mock_link, mock_copyfile, mock_makedirs): - CONF.deploy.http_url = 'http://10.0.0.2' - CONF.deploy.external_http_url = None - CONF.deploy.http_root = '/httproot' + CONF.set_override('http_url', 'http://10.0.0.2', 'deploy') + CONF.set_override('external_http_url', None, 'deploy') + CONF.set_override('http_root', '/httproot', 'deploy') node = mock.Mock(uuid='55cdaba0-1123-4622-8b37-bb52dd6285d3') mock_link.side_effect = OSError @@ -323,9 +323,9 @@ class FirmwareUtilsTestCase(base.TestCase): @mock.patch.object(os, 'chmod', autospec=True) def test_stage_http_copyfile_fails(self, mock_chmod, mock_link, mock_copyfile, mock_makedirs): - CONF.deploy.http_url = 'http://10.0.0.2' - CONF.deploy.external_http_url = None - CONF.deploy.http_root = '/httproot' + CONF.set_override('http_url', 'http://10.0.0.2', 'deploy') + CONF.set_override('external_http_url', None, 'deploy') + CONF.set_override('http_root', '/httproot', 'deploy') node = mock.Mock(uuid='55cdaba0-1123-4622-8b37-bb52dd6285d3') mock_link.side_effect = OSError mock_copyfile.side_effect = IOError @@ -352,9 +352,9 @@ class FirmwareUtilsTestCase(base.TestCase): @mock.patch.object(os, 'chmod', autospec=True) def test_stage_local_external(self, mock_chmod, mock_link, mock_rmtree, mock_copyfile, mock_makedirs): - CONF.deploy.http_url = 'http://10.0.0.2' - CONF.deploy.external_http_url = 'http://90.0.0.9' - CONF.deploy.http_root = '/httproot' + CONF.set_override('http_url', 'http://10.0.0.2', 'deploy') + CONF.set_override('external_http_url', 'http://90.0.0.9', 'deploy') + CONF.set_override('http_root', '/httproot', 'deploy') node = mock.Mock(uuid='55cdaba0-1123-4622-8b37-bb52dd6285d3') staged_url, need_cleanup = firmware_utils.stage( @@ -402,7 +402,7 @@ class FirmwareUtilsTestCase(base.TestCase): @mock.patch.object(swift, 'SwiftAPI', autospec=True) def test_cleanup(self, mock_swift_api, mock_gettempdir, mock_rmtree): mock_gettempdir.return_value = '/tmp' - CONF.deploy.http_root = '/httproot' + CONF.set_override('http_root', '/httproot', 'deploy') node = mock.Mock( uuid='55cdaba0-1123-4622-8b37-bb52dd6285d3', driver_internal_info={'firmware_cleanup': ['http', 'swift']}) |