Merge "Removes legacy Exception for 300 HTTP status"

This commit is contained in:
Jenkins 2014-10-31 12:48:31 +00:00 committed by Gerrit Code Review
commit d779196dd6
3 changed files with 2 additions and 25 deletions

View File

@ -168,7 +168,7 @@ class HTTPClient(object):
else:
self.log_http_response(resp)
if 400 <= resp.status < 600:
if 400 <= resp.status < 600 or resp.status == 300:
LOG.warn("Request returned failure status.")
# NOTE(akrivoka): from_response() method expects a
# requests.Response object so we have to convert from
@ -182,11 +182,6 @@ class HTTPClient(object):
# Redirected. Reissue the request to the new location.
new_location = resp.getheader('location')
return self._http_request(new_location, method, **kwargs)
elif resp.status == 300:
# TODO(viktors): we should use exception for status 300 from common
# code, when we will have required exception in Oslo
# See patch https://review.openstack.org/#/c/63111/
raise tuskar_exc.from_response(resp)
return resp, body_iter

View File

@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import sys
from tuskarclient.openstack.common.apiclient import exceptions as exc
@ -40,18 +38,3 @@ class HTTPMultipleChoices(exc.HttpError):
"available.")
return "%s (HTTP %s) %s" % (self.__class__.__name__, self.code,
self.details)
# NOTE(bcwaldon): Build a mapping of HTTP codes to corresponding exception
# classes
_code_map = {}
for obj_name in dir(sys.modules[__name__]):
if obj_name.startswith('HTTP'):
obj = getattr(sys.modules[__name__], obj_name)
_code_map[obj.code] = obj
def from_response(response):
"""Return an instance of an exc.HttpError based on httplib response."""
cls = _code_map.get(response.status, exc.HttpError)
return cls()

View File

@ -16,7 +16,6 @@
import mock
from tuskarclient.common import http
from tuskarclient import exc as tuskar_exc
from tuskarclient.openstack.common.apiclient import exceptions as exc
from tuskarclient.tests import utils as tutils
@ -166,7 +165,7 @@ class HttpClientHTTPRequestTest(tutils.TestCase):
self.mock_response.status = 300
args = self.call_args.copy()
self.assertRaises(tuskar_exc.HTTPMultipleChoices,
self.assertRaises(exc.MultipleChoices,
self.client._http_request,
args['provided_url'], args['provided_method'],
**args['provided_args'])