Merge "Test: make enforce_type=True in CONF.set_override"

This commit is contained in:
Jenkins 2016-05-14 11:43:39 +00:00 committed by Gerrit Code Review
commit 93b465b97b
11 changed files with 32 additions and 24 deletions

View File

@ -173,7 +173,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)
CONF.set_override(k, v, enforce_type=True)
def start_service(self, name, host=None, **kwargs):
host = host and host or uuid.uuid4().hex

View File

@ -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')
CONF.set_override('log_dir', 'fake-dir', enforce_type=True)
listdir.return_value = ['fake-error.log']
with mock.patch('sys.stdout', new=six.StringIO()) as fake_out:

View File

@ -39,8 +39,9 @@ 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)
CONF.set_override('host', fake_host)
CONF.set_override('enabled_share_backends', backends,
enforce_type=True)
CONF.set_override('host', fake_host, enforce_type=True)
sys.argv = ['manila-share']
manila_share.main()

View File

@ -351,7 +351,8 @@ 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")
"admin",
enforce_type=True)
self._driver.create_share(self._context,
self._share)

View File

@ -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_replication_opts)
CONF.set_override("share_backend_name", self.backend,
group=self.backend)
group=self.backend, enforce_type=True)
CONF.set_override("netapp_transport_type", "https",
group=self.backend)
group=self.backend, enforce_type=True)
CONF.set_override("netapp_login", "fake_user",
group=self.backend)
group=self.backend, enforce_type=True)
CONF.set_override("netapp_password", "fake_password",
group=self.backend)
group=self.backend, enforce_type=True)
CONF.set_override("netapp_server_hostname", "fake_hostname",
group=self.backend)
group=self.backend, enforce_type=True)
CONF.set_override("netapp_server_port", 8866,
group=self.backend)
group=self.backend, enforce_type=True)
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)
group=self.backend, enforce_type=True)
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)
group=self.backend, enforce_type=True)
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)
group=self.backend, enforce_type=True)
CONF.set_override("share_backend_name", "fake_backend_name",
group=self.backend)
group=self.backend, enforce_type=True)
data_motion.CONF.list_all_sections.return_value = [self.backend]
config = data_motion.get_backend_configuration(self.backend)

View File

@ -567,7 +567,8 @@ SSC_DISK_TYPES = {
def get_config_cmode():
config = na_fakes.create_configuration_cmode()
config.local_conf.set_override('share_backend_name', BACKEND_NAME)
config.local_conf.set_override('share_backend_name', BACKEND_NAME,
enforce_type=True)
config.reserved_share_percentage = 5
config.netapp_login = CLIENT_KWARGS['username']
config.netapp_password = CLIENT_KWARGS['password']

View File

@ -120,7 +120,8 @@ class NetAppDriverFactoryTestCase(test.TestCase):
config = na_fakes.create_configuration()
config.local_conf.set_override('driver_handles_share_servers',
mode == na_common.MULTI_SVM)
mode == na_common.MULTI_SVM,
enforce_type=True)
kwargs = {
'configuration': config,
'private_storage': mock.Mock(),
@ -135,7 +136,8 @@ 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)
config.local_conf.set_override('driver_handles_share_servers', True,
enforce_type=True)
kwargs = {
'configuration': config,

View File

@ -82,7 +82,7 @@ class WindowsServiceInstanceManagerTestCase(test.TestCase):
if not use_cert_auth:
mock_check_complexity.assert_called_once_with(
mock.sentinel.password)
str(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=mock.sentinel.admin_pass))
meta=dict(admin_pass=str(mock.sentinel.admin_pass)))
create_kwargs = self._mgr._get_service_instance_create_kwargs()

View File

@ -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)
CONF.set_override('answer', 256, enforce_type=True)
self.assertEqual(256, CONF.answer)
CONF.import_opt('answer', 'manila.tests.declare_conf')
self.assertEqual(256, CONF.answer)

View File

@ -41,7 +41,8 @@ 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')
CONF.set_override('policy_file', tmpfilename, group='oslo_policy',
enforce_type=True)
action = "example:test"
with open(tmpfilename, "w") as policyfile:
policyfile.write("""{"example:test": []}""")

View File

@ -113,7 +113,8 @@ 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')
cinder.CONF.set_override('cross_az_attach', False, 'cinder',
enforce_type=True)
self.assertRaises(exception.InvalidVolume,
self.api.check_attach, self.ctx, volume, instance)
volume['availability_zone'] = 'zone1'
@ -125,7 +126,8 @@ 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')
cinder.CONF.set_override('cross_az_attach', False, 'cinder',
enforce_type=True)
self.assertIsNone(self.api.check_attach(self.ctx, volume, instance))
cinder.CONF.reset()