Merge "Suppress remaining policy warnings in unit tests"

This commit is contained in:
Zuul 2020-05-11 18:16:26 +00:00 committed by Gerrit Code Review
commit 1d29344457
2 changed files with 9 additions and 6 deletions

View File

@ -256,9 +256,6 @@ class ControllerTest(test.TestCase):
self.controller = servers.ServersController()
self.ips_controller = ips.IPsController()
policy.reset()
policy.init()
self.addCleanup(policy.reset)
# Assume that anything that hits the compute API and looks for a
# RequestSpec doesn't care about it, since testing logic that deep
# should be done in nova.tests.unit.compute.test_compute_api.

View File

@ -48,7 +48,9 @@ class PolicyFileTestCase(test.NoDBTestCase):
# is_admin or not. As a side-effect, policy reset is needed here
# to flush existing policy cache.
policy.reset()
policy.init()
# NOTE(gmann): We do not need to log policy warnings for unit
# tests.
policy.init(suppress_deprecation_warnings=True)
rule = oslo_policy.RuleDefault('example:test', "")
policy._ENFORCER.register_defaults([rule])
@ -86,7 +88,9 @@ class PolicyTestCase(test.NoDBTestCase):
"role:ADMIN or role:sysadmin"),
]
policy.reset()
policy.init()
# NOTE(gmann): We do not need to log policy warnings for unit
# tests.
policy.init(suppress_deprecation_warnings=True)
# before a policy rule can be used, its default has to be registered.
policy._ENFORCER.register_defaults(rules)
self.context = context.RequestContext('fake', 'fake', roles=['member'])
@ -232,7 +236,9 @@ class PolicyTestCase(test.NoDBTestCase):
class IsAdminCheckTestCase(test.NoDBTestCase):
def setUp(self):
super(IsAdminCheckTestCase, self).setUp()
policy.init()
# NOTE(gmann): We do not need to log policy warnings for unit
# tests.
policy.init(suppress_deprecation_warnings=True)
def test_init_true(self):
check = policy.IsAdminCheck('is_admin', 'True')