Change tempest InvalidContentType exc to tempest-lib exc
This commit changes tempest.exceptions.InvalidContentType to tempest_lib.exceptions.InvalidContentType. This is one of the migrating rest client to tempest-lib works. Change-Id: Ia50f62ab80df3a8f0a3c045ed8b22465566cff30
This commit is contained in:
parent
dd7590832a
commit
d5f3b6cf73
|
@ -29,6 +29,7 @@ import urlparse
|
|||
|
||||
import OpenSSL
|
||||
from six import moves
|
||||
from tempest_lib import exceptions as lib_exc
|
||||
|
||||
from tempest import exceptions as exc
|
||||
from tempest.openstack.common import log as logging
|
||||
|
@ -164,7 +165,7 @@ class HTTPClient(object):
|
|||
kwargs['headers'].setdefault('Content-Type', 'application/json')
|
||||
if kwargs['headers']['Content-Type'] != 'application/json':
|
||||
msg = "Only application/json content-type is supported."
|
||||
raise exc.InvalidContentType(msg)
|
||||
raise lib_exc.InvalidContentType(msg)
|
||||
|
||||
if 'body' in kwargs:
|
||||
kwargs['body'] = json.dumps(kwargs['body'])
|
||||
|
@ -179,7 +180,7 @@ class HTTPClient(object):
|
|||
LOG.error('Could not decode response body as JSON')
|
||||
else:
|
||||
msg = "Only json/application content-type is supported."
|
||||
raise exc.InvalidContentType(msg)
|
||||
raise lib_exc.InvalidContentType(msg)
|
||||
|
||||
return resp, body
|
||||
|
||||
|
|
|
@ -69,8 +69,6 @@ class ServiceClient(rest_client.RestClient):
|
|||
raise exceptions.Conflict(ex)
|
||||
except lib_exceptions.OverLimit as ex:
|
||||
raise exceptions.OverLimit(ex)
|
||||
except lib_exceptions.InvalidContentType as ex:
|
||||
raise exceptions.InvalidContentType(ex)
|
||||
# TODO(oomichi): This is just a workaround for failing gate tests
|
||||
# when separating Forbidden from Unauthorized in tempest-lib.
|
||||
# We will need to remove this translation and replace negative tests
|
||||
|
|
|
@ -185,10 +185,6 @@ class InvalidHTTPResponseHeader(RestClientException):
|
|||
message = "HTTP response header is invalid"
|
||||
|
||||
|
||||
class InvalidContentType(RestClientException):
|
||||
message = "Invalid content type provided"
|
||||
|
||||
|
||||
class InvalidStructure(TempestException):
|
||||
message = "Invalid structure of table with details"
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import socket
|
|||
|
||||
import mock
|
||||
import six
|
||||
from tempest_lib import exceptions as lib_exc
|
||||
|
||||
from tempest.common import glance_http
|
||||
from tempest import exceptions
|
||||
|
@ -57,18 +58,18 @@ class TestGlanceHTTPClient(base.TestCase):
|
|||
|
||||
def test_json_request_without_content_type_header_in_response(self):
|
||||
self._set_response_fixture({}, 200, 'fake_response_body')
|
||||
self.assertRaises(exceptions.InvalidContentType,
|
||||
self.assertRaises(lib_exc.InvalidContentType,
|
||||
self.client.json_request, 'GET', '/images')
|
||||
|
||||
def test_json_request_with_xml_content_type_header_in_request(self):
|
||||
self.assertRaises(exceptions.InvalidContentType,
|
||||
self.assertRaises(lib_exc.InvalidContentType,
|
||||
self.client.json_request, 'GET', '/images',
|
||||
headers={'Content-Type': 'application/xml'})
|
||||
|
||||
def test_json_request_with_xml_content_type_header_in_response(self):
|
||||
self._set_response_fixture({'content-type': 'application/xml'},
|
||||
200, 'fake_response_body')
|
||||
self.assertRaises(exceptions.InvalidContentType,
|
||||
self.assertRaises(lib_exc.InvalidContentType,
|
||||
self.client.json_request, 'GET', '/images')
|
||||
|
||||
def test_json_request_with_json_content_type_header_only_in_resp(self):
|
||||
|
|
Loading…
Reference in New Issue