From 4e25ce5a0c5c6100bc164729063659fd1472d391 Mon Sep 17 00:00:00 2001 From: Tom Barron Date: Sun, 16 Apr 2017 09:42:54 -0400 Subject: [PATCH] Remove usage of parameter enforce_type oslo.config has deprecated the enforce_type parameter to set_override() and set its default value to True [1], so remove this usage from our codebase. Also remove explict str() cast of mock.sentinel_password in Windows driver since it should no longer be expected. [1] Ifa552de0a994e40388cbc9f7dbaa55700ca276b0 Change-Id: Ic02cbb37c6dbf30cacb1e6e290bfb0986f54d5f3 --- manila/test.py | 2 +- manila/tests/cmd/test_manage.py | 2 +- manila/tests/cmd/test_share.py | 5 ++--- .../drivers/cephfs/test_cephfs_native.py | 3 +-- .../cluster_mode/test_data_motion.py | 20 +++++++++---------- .../share/drivers/netapp/dataontap/fakes.py | 3 +-- .../tests/share/drivers/netapp/test_common.py | 6 ++---- .../drivers/windows/test_service_instance.py | 4 ++-- manila/tests/test_conf.py | 2 +- manila/tests/test_policy.py | 3 +-- manila/tests/volume/test_cinder.py | 6 ++---- 11 files changed, 24 insertions(+), 32 deletions(-) diff --git a/manila/test.py b/manila/test.py index b6e3487e5e..0382392bcd 100644 --- a/manila/test.py +++ b/manila/test.py @@ -181,7 +181,7 @@ class TestCase(base_test.BaseTestCase): def flags(self, **kw): """Override flag variables for a test.""" for k, v in kw.items(): - CONF.set_override(k, v, enforce_type=True) + CONF.set_override(k, v) def start_service(self, name, host=None, **kwargs): host = host and host or uuidutils.generate_uuid() diff --git a/manila/tests/cmd/test_manage.py b/manila/tests/cmd/test_manage.py index fd73c90b8d..0e1d012bf0 100644 --- a/manila/tests/cmd/test_manage.py +++ b/manila/tests/cmd/test_manage.py @@ -260,7 +260,7 @@ class ManilaCmdManageTestCase(test.TestCase): @mock.patch('six.moves.builtins.open') @mock.patch('os.listdir') def test_get_log_commands_errors(self, listdir, open): - CONF.set_override('log_dir', 'fake-dir', enforce_type=True) + CONF.set_override('log_dir', 'fake-dir') listdir.return_value = ['fake-error.log'] with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: diff --git a/manila/tests/cmd/test_share.py b/manila/tests/cmd/test_share.py index ddca6915a3..630da9d9ec 100644 --- a/manila/tests/cmd/test_share.py +++ b/manila/tests/cmd/test_share.py @@ -39,9 +39,8 @@ class ManilaCmdShareTestCase(test.TestCase): self.mock_object(self.launcher, 'wait') self.server = manila_share.service.Service.create.return_value fake_host = 'fake.host' - CONF.set_override('enabled_share_backends', backends, - enforce_type=True) - CONF.set_override('host', fake_host, enforce_type=True) + CONF.set_override('enabled_share_backends', backends) + CONF.set_override('host', fake_host) sys.argv = ['manila-share'] manila_share.main() diff --git a/manila/tests/share/drivers/cephfs/test_cephfs_native.py b/manila/tests/share/drivers/cephfs/test_cephfs_native.py index b491b3ff27..d2564af92e 100644 --- a/manila/tests/share/drivers/cephfs/test_cephfs_native.py +++ b/manila/tests/share/drivers/cephfs/test_cephfs_native.py @@ -427,8 +427,7 @@ class CephFSNativeDriverTestCase(test.TestCase): def test_connect_noevict(self): # When acting as "admin", driver should skip evicting self._driver.configuration.local_conf.set_override('cephfs_auth_id', - "admin", - enforce_type=True) + "admin") self._driver.create_share(self._context, self._share) diff --git a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_data_motion.py b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_data_motion.py index 57107b6fcd..074c1e09ec 100644 --- a/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_data_motion.py +++ b/manila/tests/share/drivers/netapp/dataontap/cluster_mode/test_data_motion.py @@ -53,17 +53,17 @@ class NetAppCDOTDataMotionTestCase(test.TestCase): self.config.append_config_values(na_opts.netapp_provisioning_opts) self.config.append_config_values(na_opts.netapp_data_motion_opts) CONF.set_override("share_backend_name", self.backend, - group=self.backend, enforce_type=True) + group=self.backend) CONF.set_override("netapp_transport_type", "https", - group=self.backend, enforce_type=True) + group=self.backend) CONF.set_override("netapp_login", "fake_user", - group=self.backend, enforce_type=True) + group=self.backend) CONF.set_override("netapp_password", "fake_password", - group=self.backend, enforce_type=True) + group=self.backend) CONF.set_override("netapp_server_hostname", "fake.hostname", - group=self.backend, enforce_type=True) + group=self.backend) CONF.set_override("netapp_server_port", 8866, - group=self.backend, enforce_type=True) + group=self.backend) def test_get_client_for_backend(self): self.mock_object(data_motion, "get_backend_configuration", @@ -81,7 +81,7 @@ class NetAppCDOTDataMotionTestCase(test.TestCase): mock.Mock(return_value=self.config)) CONF.set_override("netapp_vserver", 'fake_vserver', - group=self.backend, enforce_type=True) + group=self.backend) data_motion.get_client_for_backend(self.backend) @@ -93,7 +93,7 @@ class NetAppCDOTDataMotionTestCase(test.TestCase): def test_get_config_for_backend(self): self.mock_object(data_motion, "CONF") CONF.set_override("netapp_vserver", 'fake_vserver', - group=self.backend, enforce_type=True) + group=self.backend) data_motion.CONF.list_all_sections.return_value = [self.backend] config = data_motion.get_backend_configuration(self.backend) @@ -103,9 +103,9 @@ class NetAppCDOTDataMotionTestCase(test.TestCase): def test_get_config_for_backend_different_backend_name(self): self.mock_object(data_motion, "CONF") CONF.set_override("netapp_vserver", 'fake_vserver', - group=self.backend, enforce_type=True) + group=self.backend) CONF.set_override("share_backend_name", "fake_backend_name", - group=self.backend, enforce_type=True) + group=self.backend) data_motion.CONF.list_all_sections.return_value = [self.backend] config = data_motion.get_backend_configuration(self.backend) diff --git a/manila/tests/share/drivers/netapp/dataontap/fakes.py b/manila/tests/share/drivers/netapp/dataontap/fakes.py index d8e7187986..8b28eed1f0 100644 --- a/manila/tests/share/drivers/netapp/dataontap/fakes.py +++ b/manila/tests/share/drivers/netapp/dataontap/fakes.py @@ -1183,8 +1183,7 @@ EXPANDED_PROCESSOR_COUNTERS = [ def get_config_cmode(): config = na_fakes.create_configuration_cmode() - config.local_conf.set_override('share_backend_name', BACKEND_NAME, - enforce_type=True) + config.local_conf.set_override('share_backend_name', BACKEND_NAME) config.reserved_share_percentage = 5 config.netapp_login = CLIENT_KWARGS['username'] config.netapp_password = CLIENT_KWARGS['password'] diff --git a/manila/tests/share/drivers/netapp/test_common.py b/manila/tests/share/drivers/netapp/test_common.py index a53971f95b..2008ac78eb 100644 --- a/manila/tests/share/drivers/netapp/test_common.py +++ b/manila/tests/share/drivers/netapp/test_common.py @@ -120,8 +120,7 @@ class NetAppDriverFactoryTestCase(test.TestCase): config = na_fakes.create_configuration() config.local_conf.set_override('driver_handles_share_servers', - mode == na_common.MULTI_SVM, - enforce_type=True) + mode == na_common.MULTI_SVM) kwargs = { 'configuration': config, 'private_storage': mock.Mock(), @@ -136,8 +135,7 @@ class NetAppDriverFactoryTestCase(test.TestCase): def test_create_driver_case_insensitive(self): config = na_fakes.create_configuration() - config.local_conf.set_override('driver_handles_share_servers', True, - enforce_type=True) + config.local_conf.set_override('driver_handles_share_servers', True) kwargs = { 'configuration': config, diff --git a/manila/tests/share/drivers/windows/test_service_instance.py b/manila/tests/share/drivers/windows/test_service_instance.py index eca61f0e05..7c359e0346 100644 --- a/manila/tests/share/drivers/windows/test_service_instance.py +++ b/manila/tests/share/drivers/windows/test_service_instance.py @@ -82,7 +82,7 @@ class WindowsServiceInstanceManagerTestCase(test.TestCase): if not use_cert_auth: mock_check_complexity.assert_called_once_with( - str(mock.sentinel.password)) + mock.sentinel.password) @ddt.data(False, True) def test_get_auth_info(self, use_cert_auth): @@ -165,7 +165,7 @@ class WindowsServiceInstanceManagerTestCase(test.TestCase): expected_kwargs = dict(user_data=mock_cert_data) else: expected_kwargs = dict( - meta=dict(admin_pass=str(mock.sentinel.admin_pass))) + meta=dict(admin_pass=mock.sentinel.admin_pass)) create_kwargs = self._mgr._get_service_instance_create_kwargs() diff --git a/manila/tests/test_conf.py b/manila/tests/test_conf.py index a285ef64ed..2c9e897a0f 100644 --- a/manila/tests/test_conf.py +++ b/manila/tests/test_conf.py @@ -38,7 +38,7 @@ class ConfigTestCase(test.TestCase): self.assertEqual(42, CONF.answer) # Make sure we don't overwrite anything - CONF.set_override('answer', 256, enforce_type=True) + CONF.set_override('answer', 256) self.assertEqual(256, CONF.answer) CONF.import_opt('answer', 'manila.tests.declare_conf') self.assertEqual(256, CONF.answer) diff --git a/manila/tests/test_policy.py b/manila/tests/test_policy.py index b99d53dc86..354b59351c 100644 --- a/manila/tests/test_policy.py +++ b/manila/tests/test_policy.py @@ -41,8 +41,7 @@ class PolicyFileTestCase(test.TestCase): def test_modified_policy_reloads(self): with utils.tempdir() as tmpdir: tmpfilename = os.path.join(tmpdir, 'policy') - CONF.set_override('policy_file', tmpfilename, group='oslo_policy', - enforce_type=True) + CONF.set_override('policy_file', tmpfilename, group='oslo_policy') action = "example:test" with open(tmpfilename, "w") as policyfile: policyfile.write("""{"example:test": []}""") diff --git a/manila/tests/volume/test_cinder.py b/manila/tests/volume/test_cinder.py index 5082993e34..ea32c11402 100644 --- a/manila/tests/volume/test_cinder.py +++ b/manila/tests/volume/test_cinder.py @@ -190,8 +190,7 @@ class CinderApiTestCase(test.TestCase): volume['attach_status'] = "detached" instance = {'availability_zone': 'zone1'} volume['availability_zone'] = 'zone2' - cinder.CONF.set_override('cross_az_attach', False, 'cinder', - enforce_type=True) + cinder.CONF.set_override('cross_az_attach', False, 'cinder') self.assertRaises(exception.InvalidVolume, self.api.check_attach, self.ctx, volume, instance) volume['availability_zone'] = 'zone1' @@ -203,8 +202,7 @@ class CinderApiTestCase(test.TestCase): volume['attach_status'] = "detached" volume['availability_zone'] = 'zone1' instance = {'availability_zone': 'zone1'} - cinder.CONF.set_override('cross_az_attach', False, 'cinder', - enforce_type=True) + cinder.CONF.set_override('cross_az_attach', False, 'cinder') self.assertIsNone(self.api.check_attach(self.ctx, volume, instance)) cinder.CONF.reset()