From 87aa03567bc6fe6aca5f963c27566943b07195f3 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Thu, 8 Oct 2015 13:00:23 -0700 Subject: [PATCH] Replace internal oslo_policy mock with public fixture This replaces a mock on an internal oslo_policy http class with a public fixture they provide. Related-Bug: #1503890 Change-Id: Ifa445b699f71379c7922960375a5e1d25f873f91 --- neutron/tests/unit/test_policy.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/neutron/tests/unit/test_policy.py b/neutron/tests/unit/test_policy.py index 9140586c9..b2002422d 100644 --- a/neutron/tests/unit/test_policy.py +++ b/neutron/tests/unit/test_policy.py @@ -16,6 +16,7 @@ """Test of Policy Engine For Neutron""" import mock +from oslo_policy import fixture as op_fixture from oslo_policy import policy as oslo_policy from oslo_serialization import jsonutils from oslo_utils import importutils @@ -103,19 +104,15 @@ class PolicyTestCase(base.BaseTestCase): result = policy.enforce(self.context, action, self.target) self.assertTrue(result) - #TODO(kevinbenton): replace these private method mocks with a fixture - @mock.patch.object(oslo_policy._checks.HttpCheck, '__call__', - return_value=True) - def test_enforce_http_true(self, mock_httpcheck): + def test_enforce_http_true(self): + self.useFixture(op_fixture.HttpCheckFixture()) action = "example:get_http" target = {} result = policy.enforce(self.context, action, target) self.assertTrue(result) - #TODO(kevinbenton): replace these private method mocks with a fixture - @mock.patch.object(oslo_policy._checks.HttpCheck, '__call__', - return_value=False) - def test_enforce_http_false(self, mock_httpcheck): + def test_enforce_http_false(self): + self.useFixture(op_fixture.HttpCheckFixture(False)) action = "example:get_http" target = {} self.assertRaises(oslo_policy.PolicyNotAuthorized, -- 2.45.2