From 9c99814ce5943bd4c33bf3650b832666e31b3411 Mon Sep 17 00:00:00 2001 From: Gaurang Tapase Date: Mon, 12 Oct 2015 20:47:19 +0530 Subject: [PATCH] Fix usage of dependencies Manila is broken is threee places, so fix them: 1) test 'test_misc' with WebOb 1.5 WebOb 1.5 was released at 2015-10-11. With this new version, webob.exc.WSGIHTTPException() constructor now fails with a KeyError when the HTTP status code is 0. test_exceptions_raise() of test_misc tries to instantiate all exceptions of manila.exception. The problem is that ConvertedException uses a default HTTP status code of 0. Modify the default HTTP status code of ConvertedException to 400 to fix the unit tests. 2) Add dependency for 'testresources' that is required by migration tests. 3) Remove 2 unit tests related to testing of oslo.policy lib functionality that should not be tested in Manila. It started failing because under-the-hood behaviour was changed in new realese 0.12.0 Closes-Bug: #1505153 Closes-Bug: #1505374 Change-Id: I0f28f3c3fb2c7eec1bafc3a617344990f86810cf --- manila/exception.py | 2 +- manila/tests/test_policy.py | 25 ------------------------- test-requirements.txt | 1 + 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/manila/exception.py b/manila/exception.py index d13cf380..73865184 100644 --- a/manila/exception.py +++ b/manila/exception.py @@ -48,7 +48,7 @@ ProcessExecutionError = processutils.ProcessExecutionError class ConvertedException(webob.exc.WSGIHTTPException): - def __init__(self, code=0, title="", explanation=""): + def __init__(self, code=400, title="", explanation=""): self.code = code self.title = title self.explanation = explanation diff --git a/manila/tests/test_policy.py b/manila/tests/test_policy.py index 4ec6f655..97a8a92f 100644 --- a/manila/tests/test_policy.py +++ b/manila/tests/test_policy.py @@ -17,11 +17,8 @@ import os.path -import mock from oslo_config import cfg from oslo_policy import policy as common_policy -import six -from six.moves.urllib import request as urlrequest from manila import context from manila import exception @@ -107,28 +104,6 @@ class PolicyTestCase(test.TestCase): action = "example:allowed" policy.enforce(self.context, action, self.target) - def test_enforce_http_true(self): - - def fakeurlopen(url, post_data): - return six.StringIO("True") - - action = "example:get_http" - target = {} - with mock.patch.object(urlrequest, 'urlopen', fakeurlopen): - result = policy.enforce(self.context, action, target) - self.assertTrue(result) - - def test_enforce_http_false(self): - - def fakeurlopen(url, post_data): - return six.StringIO("False") - - action = "example:get_http" - target = {} - with mock.patch.object(urlrequest, 'urlopen', fakeurlopen): - self.assertRaises(exception.PolicyNotAuthorized, policy.enforce, - self.context, action, target) - def test_templatized_enforcement(self): target_mine = {'project_id': 'fake'} target_not_mine = {'project_id': 'another'} diff --git a/test-requirements.txt b/test-requirements.txt index 423b0659..14f3efc7 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -18,4 +18,5 @@ python-subunit>=0.0.18 requests-mock>=0.6.0 # Apache-2.0 sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 testrepository>=0.0.18 +testresources>=0.2.4 testtools>=1.4.0