]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Replace internal oslo_policy mock with public fixture
authorKevin Benton <blak111@gmail.com>
Thu, 8 Oct 2015 20:00:23 +0000 (13:00 -0700)
committerIhar Hrachyshka <ihrachys@redhat.com>
Mon, 2 Nov 2015 12:29:45 +0000 (12:29 +0000)
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

index 9140586c9859e3fe2c4087bdafc9e5497e5ff732..b2002422dfe17db8458ad041599b0d0ed0ef855f 100644 (file)
@@ -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,