Merge "Remove usage of parameter enforce_type"

This commit is contained in:
Jenkins
2017-06-02 01:26:10 +00:00
committed by Gerrit Code Review
13 changed files with 22 additions and 34 deletions

View File

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

View File

@@ -120,7 +120,7 @@ class TestNoExceptionTracebackHook(base.FunctionalTest):
p = mock.patch.object(root.Root, 'convert') p = mock.patch.object(root.Root, 'convert')
self.root_convert_mock = p.start() self.root_convert_mock = p.start()
self.addCleanup(p.stop) 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): def test_hook_exception_success(self):
self.root_convert_mock.side_effect = Exception(self.MSG_WITH_TRACE) self.root_convert_mock.side_effect = Exception(self.MSG_WITH_TRACE)
@@ -164,7 +164,7 @@ class TestNoExceptionTracebackHook(base.FunctionalTest):
self._test_hook_without_traceback() self._test_hook_without_traceback()
def test_hook_without_traceback_debug(self): 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() self._test_hook_without_traceback()
def _test_hook_on_serverfault(self): def _test_hook_on_serverfault(self):
@@ -177,12 +177,12 @@ class TestNoExceptionTracebackHook(base.FunctionalTest):
return actual_msg return actual_msg
def test_hook_on_serverfault(self): 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() msg = self._test_hook_on_serverfault()
self.assertEqual(self.MSG_WITHOUT_TRACE, msg) self.assertEqual(self.MSG_WITHOUT_TRACE, msg)
def test_hook_on_serverfault_debug(self): 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() msg = self._test_hook_on_serverfault()
self.assertEqual(self.MSG_WITH_TRACE, msg) self.assertEqual(self.MSG_WITH_TRACE, msg)
@@ -202,7 +202,7 @@ class TestNoExceptionTracebackHook(base.FunctionalTest):
self.assertEqual(self.MSG_WITHOUT_TRACE, msg) self.assertEqual(self.MSG_WITHOUT_TRACE, msg)
def test_hook_on_clientfault_debug_tracebacks(self): 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() msg = self._test_hook_on_clientfault()
self.assertEqual(self.MSG_WITH_TRACE, msg) self.assertEqual(self.MSG_WITH_TRACE, msg)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -116,7 +116,7 @@ class TestListGoal(api_base.FunctionalTest):
self.context, id=idx, self.context, id=idx,
uuid=utils.generate_uuid(), uuid=utils.generate_uuid(),
name='GOAL_{0}'.format(idx)) 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') response = self.get_json('/goals')
self.assertEqual(3, len(response['goals'])) self.assertEqual(3, len(response['goals']))

View File

@@ -109,7 +109,7 @@ class TestListScoringEngine(api_base.FunctionalTest):
obj_utils.create_test_scoring_engine( obj_utils.create_test_scoring_engine(
self.context, id=idx, uuid=utils.generate_uuid(), self.context, id=idx, uuid=utils.generate_uuid(),
name=str(idx), description='SE_{0}'.format(idx)) 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') response = self.get_json('/scoring_engines')
self.assertEqual(3, len(response['scoring_engines'])) self.assertEqual(3, len(response['scoring_engines']))

View File

@@ -127,7 +127,7 @@ class TestListService(api_base.FunctionalTest):
self.context, id=idx, self.context, id=idx,
host='CONTROLLER', host='CONTROLLER',
name='SERVICE_{0}'.format(idx)) 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') response = self.get_json('/services')
self.assertEqual(3, len(response['services'])) self.assertEqual(3, len(response['services']))

View File

@@ -128,7 +128,7 @@ class TestListStrategy(api_base.FunctionalTest):
self.context, id=idx, self.context, id=idx,
uuid=utils.generate_uuid(), uuid=utils.generate_uuid(),
name='STRATEGY_{0}'.format(idx)) 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') response = self.get_json('/strategies')
self.assertEqual(3, len(response['strategies'])) self.assertEqual(3, len(response['strategies']))

View File

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

View File

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