Remove usage of parameter enforce_type

Oslo.config deprecated parameter enforce_type and change
its default value to True. 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: I59621664773ee5ad264e6da9b15231f30dbb9c40
Closes-Bug: #1694616
This commit is contained in:
Feng Shengqin 2017-06-01 10:11:57 +08:00
parent 590bd43a1d
commit f47fd9ac5e
13 changed files with 22 additions and 34 deletions

@ -51,11 +51,9 @@ class FunctionalTest(base.DbTestCase):
def setUp(self):
super(FunctionalTest, self).setUp()
cfg.CONF.set_override("auth_version", "v2.0",
group='keystone_authtoken',
enforce_type=True)
group='keystone_authtoken')
cfg.CONF.set_override("admin_user", "admin",
group='keystone_authtoken',
enforce_type=True)
group='keystone_authtoken')
p_services = mock.patch.object(n_service, "send_service_update",
new_callable=mock.PropertyMock)

@ -120,7 +120,7 @@ class TestNoExceptionTracebackHook(base.FunctionalTest):
p = mock.patch.object(root.Root, 'convert')
self.root_convert_mock = p.start()
self.addCleanup(p.stop)
cfg.CONF.set_override('debug', False, enforce_type=True)
cfg.CONF.set_override('debug', False)
def test_hook_exception_success(self):
self.root_convert_mock.side_effect = Exception(self.MSG_WITH_TRACE)
@ -164,7 +164,7 @@ class TestNoExceptionTracebackHook(base.FunctionalTest):
self._test_hook_without_traceback()
def test_hook_without_traceback_debug(self):
cfg.CONF.set_override('debug', True, enforce_type=True)
cfg.CONF.set_override('debug', True)
self._test_hook_without_traceback()
def _test_hook_on_serverfault(self):
@ -177,12 +177,12 @@ class TestNoExceptionTracebackHook(base.FunctionalTest):
return actual_msg
def test_hook_on_serverfault(self):
cfg.CONF.set_override('debug', False, enforce_type=True)
cfg.CONF.set_override('debug', False)
msg = self._test_hook_on_serverfault()
self.assertEqual(self.MSG_WITHOUT_TRACE, msg)
def test_hook_on_serverfault_debug(self):
cfg.CONF.set_override('debug', True, enforce_type=True)
cfg.CONF.set_override('debug', True)
msg = self._test_hook_on_serverfault()
self.assertEqual(self.MSG_WITH_TRACE, msg)
@ -202,7 +202,7 @@ class TestNoExceptionTracebackHook(base.FunctionalTest):
self.assertEqual(self.MSG_WITHOUT_TRACE, msg)
def test_hook_on_clientfault_debug_tracebacks(self):
cfg.CONF.set_override('debug', True, enforce_type=True)
cfg.CONF.set_override('debug', True)
msg = self._test_hook_on_clientfault()
self.assertEqual(self.MSG_WITH_TRACE, msg)

@ -41,8 +41,7 @@ class TestApiUtilsValidScenarios(base.TestCase):
]
def test_validate_limit(self):
cfg.CONF.set_override("max_limit", self.max_limit, group="api",
enforce_type=True)
cfg.CONF.set_override("max_limit", self.max_limit, group="api")
actual_limit = v1_utils.validate_limit(self.limit)
self.assertEqual(self.expected, actual_limit)
@ -54,8 +53,7 @@ class TestApiUtilsInvalidScenarios(base.TestCase):
]
def test_validate_limit_invalid_cases(self):
cfg.CONF.set_override("max_limit", self.max_limit, group="api",
enforce_type=True)
cfg.CONF.set_override("max_limit", self.max_limit, group="api")
self.assertRaises(
wsme.exc.ClientSideError, v1_utils.validate_limit, self.limit
)

@ -384,8 +384,7 @@ class TestListAction(api_base.FunctionalTest):
self.assertEqual(3, len(response['actions']))
def test_collection_links_default_limit(self):
cfg.CONF.set_override('max_limit', 3, 'api',
enforce_type=True)
cfg.CONF.set_override('max_limit', 3, 'api')
for id_ in range(5):
obj_utils.create_test_action(self.context, id=id_,
uuid=utils.generate_uuid())

@ -273,8 +273,7 @@ class TestListActionPlan(api_base.FunctionalTest):
self.assertIn(next_marker, response['next'])
def test_collection_links_default_limit(self):
cfg.CONF.set_override('max_limit', 3, 'api',
enforce_type=True)
cfg.CONF.set_override('max_limit', 3, 'api')
for id_ in range(5):
obj_utils.create_test_action_plan(
self.context, id=id_, uuid=utils.generate_uuid())

@ -231,8 +231,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup):
self.assertIn(next_marker, response['next'])
def test_collection_links_default_limit(self):
cfg.CONF.set_override('max_limit', 3, 'api',
enforce_type=True)
cfg.CONF.set_override('max_limit', 3, 'api')
for id_ in range(5):
obj_utils.create_test_audit_template(
self.context, id=id_, uuid=utils.generate_uuid(),

@ -234,8 +234,7 @@ class TestListAudit(api_base.FunctionalTest):
self.assertIn(next_marker, response['next'])
def test_collection_links_default_limit(self):
cfg.CONF.set_override('max_limit', 3, 'api',
enforce_type=True)
cfg.CONF.set_override('max_limit', 3, 'api')
for id_ in range(5):
obj_utils.create_test_audit(self.context, id=id_,
uuid=utils.generate_uuid())

@ -116,7 +116,7 @@ class TestListGoal(api_base.FunctionalTest):
self.context, id=idx,
uuid=utils.generate_uuid(),
name='GOAL_{0}'.format(idx))
cfg.CONF.set_override('max_limit', 3, 'api', enforce_type=True)
cfg.CONF.set_override('max_limit', 3, 'api')
response = self.get_json('/goals')
self.assertEqual(3, len(response['goals']))

@ -109,7 +109,7 @@ class TestListScoringEngine(api_base.FunctionalTest):
obj_utils.create_test_scoring_engine(
self.context, id=idx, uuid=utils.generate_uuid(),
name=str(idx), description='SE_{0}'.format(idx))
cfg.CONF.set_override('max_limit', 3, 'api', enforce_type=True)
cfg.CONF.set_override('max_limit', 3, 'api')
response = self.get_json('/scoring_engines')
self.assertEqual(3, len(response['scoring_engines']))

@ -127,7 +127,7 @@ class TestListService(api_base.FunctionalTest):
self.context, id=idx,
host='CONTROLLER',
name='SERVICE_{0}'.format(idx))
cfg.CONF.set_override('max_limit', 3, 'api', enforce_type=True)
cfg.CONF.set_override('max_limit', 3, 'api')
response = self.get_json('/services')
self.assertEqual(3, len(response['services']))

@ -128,7 +128,7 @@ class TestListStrategy(api_base.FunctionalTest):
self.context, id=idx,
uuid=utils.generate_uuid(),
name='STRATEGY_{0}'.format(idx))
cfg.CONF.set_override('max_limit', 3, 'api', enforce_type=True)
cfg.CONF.set_override('max_limit', 3, 'api')
response = self.get_json('/strategies')
self.assertEqual(3, len(response['strategies']))

@ -59,11 +59,9 @@ class TestCase(BaseTestCase):
self.messaging_conf.transport_driver = 'fake'
cfg.CONF.set_override("auth_type", "admin_token",
group='keystone_authtoken',
enforce_type=True)
group='keystone_authtoken')
cfg.CONF.set_override("auth_uri", "http://127.0.0.1/identity",
group='keystone_authtoken',
enforce_type=True)
group='keystone_authtoken')
app_config_path = os.path.join(os.path.dirname(__file__), 'config.py')
self.app = testing.load_test_app(app_config_path)
@ -128,7 +126,7 @@ class TestCase(BaseTestCase):
"""Override config options for a test."""
group = kw.pop('group', None)
for k, v in kw.items():
CONF.set_override(k, v, group, enforce_type=True)
CONF.set_override(k, v, group)
def get_path(self, project_file=None):
"""Get the absolute path to a file. Used for testing the API.

@ -70,11 +70,9 @@ class DbTestCase(base.TestCase):
return next(self._id_gen)
def setUp(self):
cfg.CONF.set_override("enable_authentication", False,
enforce_type=True)
cfg.CONF.set_override("enable_authentication", False)
# To use in-memory SQLite DB
cfg.CONF.set_override("connection", "sqlite://", group="database",
enforce_type=True)
cfg.CONF.set_override("connection", "sqlite://", group="database")
super(DbTestCase, self).setUp()