# Path: glanceclient/exc.py
# class BaseException(Exception):
# class CommandError(BaseException):
# class InvalidEndpoint(BaseException):
# class CommunicationError(BaseException):
# class ClientException(Exception):
# class HTTPException(ClientException):
# class HTTPMultipleChoices(HTTPException):
# class BadRequest(HTTPException):
# class HTTPBadRequest(BadRequest):
# class Unauthorized(HTTPException):
# class HTTPUnauthorized(Unauthorized):
# class Forbidden(HTTPException):
# class HTTPForbidden(Forbidden):
# class NotFound(HTTPException):
# class HTTPNotFound(NotFound):
# class HTTPMethodNotAllowed(HTTPException):
# class Conflict(HTTPException):
# class HTTPConflict(Conflict):
# class OverLimit(HTTPException):
# class HTTPOverLimit(OverLimit):
# class HTTPInternalServerError(HTTPException):
# class HTTPNotImplemented(HTTPException):
# class HTTPBadGateway(HTTPException):
# class ServiceUnavailable(HTTPException):
# class HTTPServiceUnavailable(ServiceUnavailable):
# class NoTokenLookupException(Exception):
# class EndpointNotFound(Exception):
# class SSLConfigurationError(BaseException):
# class SSLCertificateError(BaseException):
#     def __init__(self, message=None):
#     def __str__(self):
#     def __init__(self, details=None):
#     def __str__(self):
#     def __str__(self):
# def from_response(response, body=None):


import testtools
from unittest import mock
from glanceclient import exc
  Entity could not be found
  <br /><br />
 </body>
</html>"""


class TestHTTPExceptions(testtools.TestCase):
    def test_from_response(self):
        """exc.from_response should return instance of an HTTP exception."""
        mock_resp = mock.Mock()
        mock_resp.status_code = 400
        out = exc.from_response(mock_resp)
        self.assertIsInstance(out, exc.HTTPBadRequest)

    def test_handles_json(self):
        """exc.from_response should not print JSON."""
        mock_resp = mock.Mock()
        mock_resp.status_code = 413
        mock_resp.json.return_value = {
            "overLimit": {
                "code": 413,
                "message": "OverLimit Retry...",
                "details": "Error Details...",
                "retryAt": "2014-12-03T13:33:06Z"
            }
        }
        mock_resp.headers = {
            "content-type": "application/json"
        }
        err = exc.from_response(mock_resp, "Non-empty body")

# Path: glanceclient/exc.py
# class BaseException(Exception):
# class CommandError(BaseException):
# class InvalidEndpoint(BaseException):
# class CommunicationError(BaseException):
# class ClientException(Exception):
# class HTTPException(ClientException):
# class HTTPMultipleChoices(HTTPException):
# class BadRequest(HTTPException):
# class HTTPBadRequest(BadRequest):
# class Unauthorized(HTTPException):
# class HTTPUnauthorized(Unauthorized):
# class Forbidden(HTTPException):
# class HTTPForbidden(Forbidden):
# class NotFound(HTTPException):
# class HTTPNotFound(NotFound):
# class HTTPMethodNotAllowed(HTTPException):
# class Conflict(HTTPException):
# class HTTPConflict(Conflict):
# class OverLimit(HTTPException):
# class HTTPOverLimit(OverLimit):
# class HTTPInternalServerError(HTTPException):
# class HTTPNotImplemented(HTTPException):
# class HTTPBadGateway(HTTPException):
# class ServiceUnavailable(HTTPException):
# class HTTPServiceUnavailable(ServiceUnavailable):
# class NoTokenLookupException(Exception):
# class EndpointNotFound(Exception):
# class SSLConfigurationError(BaseException):
# class SSLCertificateError(BaseException):
#     def __init__(self, message=None):
#     def __str__(self):
#     def __init__(self, details=None):
#     def __str__(self):
#     def __str__(self):
# def from_response(response, body=None):


# Path: glanceclient/tests/unit/test_exc.py
import testtools
from unittest import mock
from glanceclient import exc

  Entity could not be found
  <br /><br />
 </body>
</html>"""


class TestHTTPExceptions(testtools.TestCase):
    def test_from_response(self):
        """exc.from_response should return instance of an HTTP exception."""
        mock_resp = mock.Mock()
        mock_resp.status_code = 400
        out = exc.from_response(mock_resp)
        self.assertIsInstance(out, exc.HTTPBadRequest)

    def test_handles_json(self):
        """exc.from_response should not print JSON."""
        mock_resp = mock.Mock()
        mock_resp.status_code = 413
        mock_resp.json.return_value = {
            "overLimit": {
                "code": 413,
                "message": "OverLimit Retry...",
                "details": "Error Details...",
                "retryAt": "2014-12-03T13:33:06Z"
            }
        }
        mock_resp.headers = {
            "content-type": "application/json"
        }
        err = exc.from_response(mock_resp, "Non-empty body")

        self.assertIsInstance(err, exc.HTTPOverLimit)