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
This commit is contained in:
Gaurang Tapase 2015-10-12 20:47:19 +05:30 committed by Valeriy Ponomaryov
parent cb4db916d3
commit 9c99814ce5
3 changed files with 2 additions and 26 deletions

View File

@ -48,7 +48,7 @@ ProcessExecutionError = processutils.ProcessExecutionError
class ConvertedException(webob.exc.WSGIHTTPException): class ConvertedException(webob.exc.WSGIHTTPException):
def __init__(self, code=0, title="", explanation=""): def __init__(self, code=400, title="", explanation=""):
self.code = code self.code = code
self.title = title self.title = title
self.explanation = explanation self.explanation = explanation

View File

@ -17,11 +17,8 @@
import os.path import os.path
import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_policy import policy as common_policy 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 context
from manila import exception from manila import exception
@ -107,28 +104,6 @@ class PolicyTestCase(test.TestCase):
action = "example:allowed" action = "example:allowed"
policy.enforce(self.context, action, self.target) 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): def test_templatized_enforcement(self):
target_mine = {'project_id': 'fake'} target_mine = {'project_id': 'fake'}
target_not_mine = {'project_id': 'another'} target_not_mine = {'project_id': 'another'}

View File

@ -18,4 +18,5 @@ python-subunit>=0.0.18
requests-mock>=0.6.0 # Apache-2.0 requests-mock>=0.6.0 # Apache-2.0
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
testrepository>=0.0.18 testrepository>=0.0.18
testresources>=0.2.4
testtools>=1.4.0 testtools>=1.4.0