From: Jenkins Date: Mon, 12 Oct 2015 09:13:37 +0000 (+0000) Subject: Merge "Use assertTrue(observed) instead of assertEqual(True, observed)" X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=abe707eade29bca45bc16c545b007055758f5bbf;p=openstack-build%2Fneutron-build.git Merge "Use assertTrue(observed) instead of assertEqual(True, observed)" --- abe707eade29bca45bc16c545b007055758f5bbf diff --cc neutron/tests/unit/test_policy.py index bed9740c9,019b9f92e..9140586c9 --- a/neutron/tests/unit/test_policy.py +++ b/neutron/tests/unit/test_policy.py @@@ -101,26 -103,27 +101,26 @@@ class PolicyTestCase(base.BaseTestCase) def test_enforce_good_action(self): action = "example:allowed" result = policy.enforce(self.context, action, self.target) - self.assertEqual(result, True) + self.assertTrue(result) - @mock.patch.object(urlrequest, 'urlopen', - return_value=six.StringIO("True")) - def test_enforce_http_true(self, mock_urlrequest): + #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): action = "example:get_http" target = {} result = policy.enforce(self.context, action, target) - self.assertEqual(result, True) + self.assertTrue(result) - def test_enforce_http_false(self): - - def fakeurlopen(url, post_data): - return six.StringIO("False") - - with mock.patch.object(urlrequest, 'urlopen', new=fakeurlopen): - action = "example:get_http" - target = {} - self.assertRaises(oslo_policy.PolicyNotAuthorized, - policy.enforce, self.context, - action, target) + #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): + action = "example:get_http" + target = {} + self.assertRaises(oslo_policy.PolicyNotAuthorized, + policy.enforce, self.context, + action, target) def test_templatized_enforcement(self): target_mine = {'tenant_id': 'fake'}