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."

Change-Id: Ic43a2c76354da9749ecad1bddb9590d8b4e0bf95
This commit is contained in:
rajat29 2017-05-17 11:52:58 +05:30
parent 6eca39d353
commit 47f84d8265
10 changed files with 28 additions and 48 deletions

View File

@ -127,8 +127,7 @@ class WhenCreatingContainersUsingContainersResource(
self.assertNotIn(self.project_id, resp.headers['Location'])
def test_should_throw_exception_when_secret_ref_doesnt_exist(self):
config.CONF.set_override("host_href", "http://localhost:9311",
enforce_type=True)
config.CONF.set_override("host_href", "http://localhost:9311")
secret_refs = [
{
'name': 'bad secret',

View File

@ -52,7 +52,7 @@ class WhenTestingVersionsResource(utils.BarbicanAPIBaseTestCase):
self.assertEqual('application/json', v1_info['media-types'][0]['base'])
def test_when_host_href_is_not_set_in_conf(self):
cmn_utils.CONF.set_override('host_href', '', enforce_type=True)
cmn_utils.CONF.set_override('host_href', '')
host_hdr = 'http://myproxy.server.com:9311'
utils.mock_pecan_request(self, host=host_hdr)
dummy_root = 'http://mylocalhost:9999'
@ -66,7 +66,7 @@ class WhenTestingVersionsResource(utils.BarbicanAPIBaseTestCase):
def test_when_host_href_is_set_in_conf(self):
host_href = 'http://myapp.server.com:9311/'
cmn_utils.CONF.set_override('host_href', host_href, enforce_type=True)
cmn_utils.CONF.set_override('host_href', host_href)
host_hdr = 'http://myproxy.server.com:9311'
utils.mock_pecan_request(self, host=host_hdr)
dummy_root = 'http://mylocalhost:9999'

View File

@ -33,7 +33,7 @@ class WhenTestingHostnameForRefsGetter(test_utils.BaseTestCase):
self._old_host = utils.CONF.host_href
self._old_version = utils.API_VERSION
utils.CONF.set_override('host_href', self.host, enforce_type=True)
utils.CONF.set_override('host_href', self.host)
utils.API_VERSION = self.version
def tearDown(self):
@ -64,7 +64,7 @@ class WhenTestingHostByWsgiRequestForRefsGetter(test_utils.BaseTestCase):
test_utils.mock_pecan_request(self, host=self.host)
utils.CONF.set_override('host_href', None, enforce_type=True)
utils.CONF.set_override('host_href', None)
utils.API_VERSION = self.version
def tearDown(self):
@ -78,7 +78,7 @@ class WhenTestingHostByWsgiRequestForRefsGetter(test_utils.BaseTestCase):
self.resource), uri)
def test_blank_conf_hosthref_for_refs(self):
utils.CONF.set_override('host_href', '', enforce_type=True)
utils.CONF.set_override('host_href', '')
uri = utils.hostname_for_refs(resource=self.resource)
self.assertEqual("{0}/{1}/{2}".format(self.host, self.version,
self.resource), uri)

View File

@ -583,8 +583,7 @@ class WhenTestingContainerValidator(utils.BaseTestCase):
def setUp(self):
super(WhenTestingContainerValidator, self).setUp()
validators.CONF.set_override("host_href", "http://localhost:9311",
enforce_type=True)
validators.CONF.set_override("host_href", "http://localhost:9311")
self.name = 'name'
self.type = 'generic'
@ -857,8 +856,7 @@ class WhenTestingRSAContainerValidator(utils.BaseTestCase):
def setUp(self):
super(WhenTestingRSAContainerValidator, self).setUp()
validators.CONF.set_override("host_href", "http://localhost:9311",
enforce_type=True)
validators.CONF.set_override("host_href", "http://localhost:9311")
self.name = 'name'
self.type = 'rsa'
@ -973,8 +971,7 @@ class WhenTestingCertificateContainerValidator(utils.BaseTestCase):
def setUp(self):
super(WhenTestingCertificateContainerValidator, self).setUp()
validators.CONF.set_override("host_href", "http://localhost:9311",
enforce_type=True)
validators.CONF.set_override("host_href", "http://localhost:9311")
self.name = 'name'
self.type = 'certificate'

View File

@ -35,10 +35,9 @@ def set_foreign_key_constraint(dbapi_connection, connection_record):
def setup_in_memory_db():
# Ensure we are using in-memory SQLite database, and creating tables.
repositories.CONF.set_override("sql_connection", "sqlite:///:memory:",
enforce_type=True)
repositories.CONF.set_override("db_auto_create", True, enforce_type=True)
repositories.CONF.set_override("debug", True, enforce_type=True)
repositories.CONF.set_override("sql_connection", "sqlite:///:memory:")
repositories.CONF.set_override("db_auto_create", True)
repositories.CONF.set_override("debug", True)
# Ensure the connection is completely closed, so any previous in-memory
# database can be removed prior to starting the next test run.

View File

@ -199,10 +199,8 @@ class WhenTestingWrapDbError(utils.BaseTestCase):
def setUp(self):
super(WhenTestingWrapDbError, self).setUp()
repositories.CONF.set_override("sql_max_retries", 0,
enforce_type=True)
repositories.CONF.set_override("sql_retry_interval", 0,
enforce_type=True)
repositories.CONF.set_override("sql_max_retries", 0)
repositories.CONF.set_override("sql_retry_interval", 0)
@mock.patch('barbican.model.repositories.is_db_connection_error')
def test_should_raise_operational_error_is_connection_error(
@ -224,8 +222,7 @@ class WhenTestingGetEnginePrivate(utils.BaseTestCase):
def setUp(self):
super(WhenTestingGetEnginePrivate, self).setUp()
repositories.CONF.set_override("sql_connection", "connection",
enforce_type=True)
repositories.CONF.set_override("sql_connection", "connection")
@mock.patch('barbican.model.repositories._create_engine')
def test_should_raise_value_exception_engine_create_failure(
@ -248,8 +245,7 @@ class WhenTestingGetEnginePrivate(utils.BaseTestCase):
def test_should_complete_with_no_alembic_create_default_configs(
self, mock_create_engine):
repositories.CONF.set_override("db_auto_create", False,
enforce_type=True)
repositories.CONF.set_override("db_auto_create", False)
engine = mock.MagicMock()
mock_create_engine.return_value = engine
@ -268,14 +264,11 @@ class WhenTestingGetEnginePrivate(utils.BaseTestCase):
def test_should_complete_with_no_alembic_create_pool_configs(
self, mock_create_engine):
repositories.CONF.set_override("db_auto_create", False,
enforce_type=True)
repositories.CONF.set_override("db_auto_create", False)
repositories.CONF.set_override(
"sql_pool_class", "QueuePool", enforce_type=True)
repositories.CONF.set_override("sql_pool_size", 22,
enforce_type=True)
repositories.CONF.set_override("sql_pool_max_overflow", 11,
enforce_type=True)
"sql_pool_class", "QueuePool")
repositories.CONF.set_override("sql_pool_size", 22)
repositories.CONF.set_override("sql_pool_max_overflow", 11)
engine = mock.MagicMock()
mock_create_engine.return_value = engine
@ -333,8 +326,7 @@ class WhenTestingMigrations(utils.BaseTestCase):
def setUp(self):
super(WhenTestingMigrations, self).setUp()
repositories.CONF.set_override("sql_connection", "connection",
enforce_type=True)
repositories.CONF.set_override("sql_connection", "connection")
self.alembic_config = migration.init_config()
self.alembic_config.barbican_config = cfg.CONF

View File

@ -53,8 +53,7 @@ class WhenTestingManager(utils.BaseTestCase):
cm.CONF.set_override(
"enabled_crypto_plugins",
['foo_plugin'],
group='crypto',
enforce_type=True)
group='crypto')
manager_to_test = cm.get_manager()

View File

@ -130,8 +130,7 @@ class WhenReadingMultipleBackendsConfig(test_utils.MultipleBackendsTestCase):
global_default_index=0)
conf = config.get_module_config('secretstore')
conf.set_override("stores_lookup_suffix", [], group='secretstore',
enforce_type=True)
conf.set_override("stores_lookup_suffix", [], group='secretstore')
self.assertRaises(exception.MultipleSecretStoreLookupFailed,
multiple_backends.read_multiple_backends_config)
@ -403,8 +402,7 @@ class TestGetApplicablePlugins(test_utils.MultipleBackendsTestCase):
ss_manager = MockedManager(ss_plugins)
ss_config.set_override("enabled_secretstore_plugins",
ss_plugins, group='secretstore',
enforce_type=True)
ss_plugins, group='secretstore')
objs = multiple_backends.get_applicable_store_plugins(ss_manager, None,
None)

View File

@ -50,14 +50,12 @@ class WhenRunningPeriodicServerRetryLogic(database_utils.RepositoryTestCase):
retry_scheduler.CONF.set_override(
"initial_delay_seconds",
2 * INITIAL_DELAY_SECONDS,
group='retry_scheduler',
enforce_type=True)
group='retry_scheduler')
retry_scheduler.CONF.set_override(
"periodic_interval_max_seconds",
NEXT_RETRY_SECONDS,
group='retry_scheduler',
enforce_type=True)
group='retry_scheduler')
self.queue_client = mock.MagicMock()
@ -165,8 +163,7 @@ class WhenRunningPeriodicServer(oslotest.BaseTestCase):
retry_scheduler.CONF.set_override(
"initial_delay_seconds",
INITIAL_DELAY_SECONDS,
group='retry_scheduler',
enforce_type=True)
group='retry_scheduler')
self.database_patcher = _DatabasePatcherHelper()
self.database_patcher.start()

View File

@ -35,8 +35,7 @@ class InitializeDatabaseMixin(object):
manager._PLUGIN_MANAGER = None
manager.CONF.set_override('enabled_crypto_plugins',
['simple_crypto'],
group='crypto',
enforce_type=True)
group='crypto')
self.project_id1 = uuid.uuid4().hex
self.project_id2 = uuid.uuid4().hex