# Path: marathon/exceptions.py
# class MarathonHttpError(MarathonError):
# 
#     def __init__(self, response):
#         """
#         :param :class:`requests.Response` response: HTTP response
#         """
#         self.error_message = response.reason or ''
#         if response.content and 'application/json' in response.headers.get('content-type', ''):
#             content = response.json()
#             self.error_message = content.get('message', self.error_message)
#             self.error_details = content.get('details')
#         self.status_code = response.status_code
#         super().__init__(self.__str__())
# 
#     def __repr__(self):
#         return 'MarathonHttpError: HTTP %s returned with message, "%s"' % \
#                (self.status_code, self.error_message)
# 
#     def __str__(self):
#         return self.__repr__()
# 
# class InternalServerError(MarathonHttpError):
#     pass


import json
import requests
from marathon.exceptions import MarathonHttpError, InternalServerError




def test_400_error():
    fake_response = requests.Response()
    fake_message = "Invalid JSON"
    fake_details = [{"path": "/taskKillGracePeriodSeconds", "errors": ["error.expected.jsnumber"]}]
    fake_response._content = json.dumps({"message": fake_message, "details": fake_details}).encode()
    fake_response.status_code = 400
    fake_response.headers['Content-Type'] = 'application/json'


# Path: marathon/exceptions.py
# class MarathonHttpError(MarathonError):
# 
#     def __init__(self, response):
#         """
#         :param :class:`requests.Response` response: HTTP response
#         """
#         self.error_message = response.reason or ''
#         if response.content and 'application/json' in response.headers.get('content-type', ''):
#             content = response.json()
#             self.error_message = content.get('message', self.error_message)
#             self.error_details = content.get('details')
#         self.status_code = response.status_code
#         super().__init__(self.__str__())
# 
#     def __repr__(self):
#         return 'MarathonHttpError: HTTP %s returned with message, "%s"' % \
#                (self.status_code, self.error_message)
# 
#     def __str__(self):
#         return self.__repr__()
# 
# class InternalServerError(MarathonHttpError):
#     pass


# Path: tests/test_exceptions.py
import json
import requests
from marathon.exceptions import MarathonHttpError, InternalServerError





def test_400_error():
    fake_response = requests.Response()
    fake_message = "Invalid JSON"
    fake_details = [{"path": "/taskKillGracePeriodSeconds", "errors": ["error.expected.jsnumber"]}]
    fake_response._content = json.dumps({"message": fake_message, "details": fake_details}).encode()
    fake_response.status_code = 400
    fake_response.headers['Content-Type'] = 'application/json'


    exc = MarathonHttpError(fake_response)