From f86d53da9fa230c7dbcdff901bd309aa966fc060 Mon Sep 17 00:00:00 2001 From: "ChangBo Guo(gcb)" Date: Fri, 5 May 2017 17:02:30 +0800 Subject: [PATCH] Remove usage of parameter enforce_type Oslo.config deprecated parameter enforce_type and change its default value to True in Ifa552de0a994e40388cbc9f7dbaa55700ca276b0. Remove the usage of it to avoid DeprecationWarning: "Using the 'enforce_type' argument is deprecated in version '4.0' and will be removed in version '5.0': The argument enforce_type has changed its default value to True and then will be removed completely." Related--Bug: #1517839 Change-Id: Ie3267df7e086e01eae6679cf01b3d9aa9b7a26cd --- ironic/tests/base.py | 1 - ironic/tests/unit/common/test_image_service.py | 6 ++---- ironic/tests/unit/common/test_neutron.py | 3 +-- ironic/tests/unit/conductor/test_rpcapi.py | 3 +-- ironic/tests/unit/drivers/modules/irmc/test_boot.py | 9 +++------ ironic/tests/unit/drivers/modules/irmc/test_common.py | 6 +++--- ironic/tests/unit/objects/test_objects.py | 9 +++------ 7 files changed, 13 insertions(+), 24 deletions(-) diff --git a/ironic/tests/base.py b/ironic/tests/base.py index 06a89e69f0..3f5f2ed41a 100644 --- a/ironic/tests/base.py +++ b/ironic/tests/base.py @@ -151,7 +151,6 @@ class TestCase(testtools.TestCase): def config(self, **kw): """Override config options for a test.""" - kw.setdefault('enforce_type', True) self.cfg_fixture.config(**kw) def set_defaults(self, **kw): diff --git a/ironic/tests/unit/common/test_image_service.py b/ironic/tests/unit/common/test_image_service.py index 84ab53ed37..ea6aa61de2 100644 --- a/ironic/tests/unit/common/test_image_service.py +++ b/ironic/tests/unit/common/test_image_service.py @@ -361,10 +361,8 @@ class ServiceGetterTestCase(base.TestCase): def test_out_range_auth_strategy(self): self.assertRaises(ValueError, cfg.CONF.set_override, - 'auth_strategy', 'fake', 'glance', - enforce_type=True) + 'auth_strategy', 'fake', 'glance') def test_out_range_glance_protocol(self): self.assertRaises(ValueError, cfg.CONF.set_override, - 'glance_protocol', 'fake', 'glance', - enforce_type=True) + 'glance_protocol', 'fake', 'glance') diff --git a/ironic/tests/unit/common/test_neutron.py b/ironic/tests/unit/common/test_neutron.py index c956b3e78a..e0c302c34c 100644 --- a/ironic/tests/unit/common/test_neutron.py +++ b/ironic/tests/unit/common/test_neutron.py @@ -105,8 +105,7 @@ class TestNeutronClient(base.TestCase): def test_out_range_auth_strategy(self, mock_client_init, mock_session): self.assertRaises(ValueError, cfg.CONF.set_override, - 'auth_strategy', 'fake', 'neutron', - enforce_type=True) + 'auth_strategy', 'fake', 'neutron') class TestNeutronNetworkActions(db_base.DbTestCase): diff --git a/ironic/tests/unit/conductor/test_rpcapi.py b/ironic/tests/unit/conductor/test_rpcapi.py index b8a8fa6034..c108c084a6 100644 --- a/ironic/tests/unit/conductor/test_rpcapi.py +++ b/ironic/tests/unit/conductor/test_rpcapi.py @@ -56,8 +56,7 @@ class ConductorRPCAPITestCase(tests_base.TestCase): @mock.patch('ironic.common.rpc.get_client') def test_version_capped(self, mock_get_client, mock_release_mapping): CONF.set_override('pin_release_version', - release_mappings.RELEASE_VERSIONS[0], - enforce_type=True) + release_mappings.RELEASE_VERSIONS[0]) mock_release_mapping.get.return_value = {'rpc': '3'} conductor_rpcapi.ConductorAPI() self.assertEqual('3', mock_get_client.call_args[1]['version_cap']) diff --git a/ironic/tests/unit/drivers/modules/irmc/test_boot.py b/ironic/tests/unit/drivers/modules/irmc/test_boot.py index 1e6dbe65a0..d515baa4dc 100644 --- a/ironic/tests/unit/drivers/modules/irmc/test_boot.py +++ b/ironic/tests/unit/drivers/modules/irmc/test_boot.py @@ -1047,10 +1047,7 @@ class IRMCVirtualMediaBootTestCase(db_base.DbTestCase): task, boot_devices.CDROM, persistent=True) def test_remote_image_share_type_values(self): - cfg.CONF.set_override('remote_image_share_type', 'cifs', 'irmc', - enforce_type=True) - cfg.CONF.set_override('remote_image_share_type', 'nfs', 'irmc', - enforce_type=True) + cfg.CONF.set_override('remote_image_share_type', 'cifs', 'irmc') + cfg.CONF.set_override('remote_image_share_type', 'nfs', 'irmc') self.assertRaises(ValueError, cfg.CONF.set_override, - 'remote_image_share_type', 'fake', 'irmc', - enforce_type=True) + 'remote_image_share_type', 'fake', 'irmc') diff --git a/ironic/tests/unit/drivers/modules/irmc/test_common.py b/ironic/tests/unit/drivers/modules/irmc/test_common.py index fdbd303332..197efaf9b3 100644 --- a/ironic/tests/unit/drivers/modules/irmc/test_common.py +++ b/ironic/tests/unit/drivers/modules/irmc/test_common.py @@ -201,12 +201,12 @@ class IRMCCommonMethodsTestCase(db_base.DbTestCase): def test_out_range_port(self): self.assertRaises(ValueError, cfg.CONF.set_override, - 'port', 60, 'irmc', enforce_type=True) + 'port', 60, 'irmc') def test_out_range_auth_method(self): self.assertRaises(ValueError, cfg.CONF.set_override, - 'auth_method', 'fake', 'irmc', enforce_type=True) + 'auth_method', 'fake', 'irmc') def test_out_range_sensor_method(self): self.assertRaises(ValueError, cfg.CONF.set_override, - 'sensor_method', 'fake', 'irmc', enforce_type=True) + 'sensor_method', 'fake', 'irmc') diff --git a/ironic/tests/unit/objects/test_objects.py b/ironic/tests/unit/objects/test_objects.py index 58c0396b9a..ff7de1e245 100644 --- a/ironic/tests/unit/objects/test_objects.py +++ b/ironic/tests/unit/objects/test_objects.py @@ -547,8 +547,7 @@ class TestObjectSerializer(test_base.TestCase): def test_serialize_entity_backport(self, mock_release_mapping): """Test single element serializer with backport.""" CONF.set_override('pin_release_version', - release_mappings.RELEASE_VERSIONS[-1], - enforce_type=True) + release_mappings.RELEASE_VERSIONS[-1]) mock_release_mapping.__getitem__.return_value = { 'objects': { 'MyObj': '1.4', @@ -571,8 +570,7 @@ class TestObjectSerializer(test_base.TestCase): @mock.patch('ironic.common.release_mappings.RELEASE_MAPPING') def test_serialize_entity_invalid_pin(self, mock_release_mapping): CONF.set_override('pin_release_version', - release_mappings.RELEASE_VERSIONS[-1], - enforce_type=True) + release_mappings.RELEASE_VERSIONS[-1]) mock_release_mapping.__getitem__.return_value = { 'objects': { 'MyObj': '1.6', @@ -586,8 +584,7 @@ class TestObjectSerializer(test_base.TestCase): @mock.patch('ironic.common.release_mappings.RELEASE_MAPPING') def test_serialize_entity_no_pin(self, mock_release_mapping): CONF.set_override('pin_release_version', - release_mappings.RELEASE_VERSIONS[-1], - enforce_type=True) + release_mappings.RELEASE_VERSIONS[-1]) mock_release_mapping.__getitem__.return_value = { 'objects': {} }