From 1edcb35a40e466f2abc5767393e840f38a4a07d2 Mon Sep 17 00:00:00 2001 From: Lance Bragstad Date: Tue, 28 Aug 2018 15:30:44 +0000 Subject: [PATCH] Loosen the assertion for logging scope type warnings We have tests to make sure we raise a 403 Forbidden in the event we catch an exception from oslo.policy due to InvalidScope. An assertion in these tests made sure we logged a warning by checking a mock was called exactly once. This is going to fail when we start deprecating policies in Stein in favor of ones that enable system scope checking. Instead of checking that assertion is called only once, let's just make sure it is called at least once with the arguments we expect. Otherwise we're going to catch false positives with the assertion because deprecated policies are also logged for operators. Change-Id: I5da718d5b31e90f1aef7d5b457b3c772eb57d1fb --- keystone/tests/unit/test_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keystone/tests/unit/test_policy.py b/keystone/tests/unit/test_policy.py index 89efe8aa55..892c6aefc6 100644 --- a/keystone/tests/unit/test_policy.py +++ b/keystone/tests/unit/test_policy.py @@ -161,7 +161,7 @@ class PolicyScopeTypesEnforcementTestCase(unit.TestCase): ) with mock.patch('warnings.warn') as mock_warn: policy.enforce(self.credentials, self.action, self.target) - mock_warn.assert_called_once_with(expected_msg) + mock_warn.assert_called_with(expected_msg) class PolicyJsonTestCase(unit.TestCase):