# Path: apiritif/http.py
# class http(object):
#     log = log.getChild('http')
# 
#     @staticmethod
#     def target(*args, **kwargs):
#         return HTTPTarget(*args, **kwargs)
# 
#     @staticmethod
#     def request(method, address, session=None,
#                 params=None, headers=None, cookies=None, data=None, json=None, files=None,
#                 encrypted_cert=None, allow_redirects=True, timeout=30):
#         """
# 
#         :param method: str
#         :param address: str
#         :return: response
#         :rtype: HTTPResponse
#         """
#         http.log.info("Request: %s %s", method, address)
#         msg = "Request: params=%r, headers=%r, cookies=%r, data=%r, json=%r, files=%r, allow_redirects=%r, timeout=%r"
#         http.log.debug(msg, params, headers, cookies, data, json, files, allow_redirects, timeout)
# 
#         if headers is None:
#             headers = {}
#         if "User-Agent" not in headers:
#             headers["User-Agent"] = "Apiritif"
# 
#         if session is None:
#             session = requests.Session()
# 
#         if encrypted_cert is not None:
#             certificate_file_path, passphrase = encrypted_cert
#             adapter = SSLAdapter(certificate_file_path=certificate_file_path, passphrase=passphrase)
#             session.mount('https://', adapter)
# 
#         request = requests.Request(method, address,
#                                    params=params, headers=headers, cookies=cookies, json=json, data=data, files=files)
#         prepared = session.prepare_request(request)
#         settings = session.merge_environment_settings(prepared.url, {}, False, False, None)
#         try:
#             response = session.send(prepared, allow_redirects=allow_redirects, timeout=timeout, **settings)
#         except requests.exceptions.Timeout as exc:
#             recorder.record_http_request_failure(method, address, prepared, exc, session)
#             raise TimeoutError("Connection to %s timed out" % address)
#         except requests.exceptions.ConnectionError as exc:
#             recorder.record_http_request_failure(method, address, prepared, exc, session)
#             raise ConnectionError("Connection to %s failed" % address)
#         except BaseException as exc:
#             recorder.record_http_request_failure(method, address, prepared, exc, session)
#             raise
#         http.log.info("Response: %s %s", response.status_code, response.reason)
#         http.log.debug("Response headers: %r", response.headers)
#         http.log.debug("Response cookies: %r", {x: response.cookies.get(x) for x in response.cookies})
#         http.log.debug('Response content: \n%s', response.content)
#         wrapped_response = HTTPResponse(response)
#         recorder.record_http_request(method, address, prepared, wrapped_response, session)
#         return wrapped_response
# 
#     @staticmethod
#     def get(address, **kwargs):
#         return http.request("GET", address, **kwargs)
# 
#     @staticmethod
#     def post(address, **kwargs):
#         return http.request("POST", address, **kwargs)
# 
#     @staticmethod
#     def put(address, **kwargs):
#         return http.request("PUT", address, **kwargs)
# 
#     @staticmethod
#     def delete(address, **kwargs):
#         return http.request("DELETE", address, **kwargs)
# 
#     @staticmethod
#     def patch(address, **kwargs):
#         return http.request("PATCH", address, **kwargs)
# 
#     @staticmethod
#     def head(address, **kwargs):
#         return http.request("HEAD", address, **kwargs)
# 
#     @staticmethod
#     def options(address, **kwargs):
#         return http.request("OPTIONS", address, **kwargs)
# 
#     @staticmethod
#     def connect(address, **kwargs):
#         return http.request("CONNECT", address, **kwargs)


from apiritif import http
from unittest import TestCase


class TestHTTPMethods(TestCase):
    def test_get(self):
        http.get('https://blazedemo.com/?tag=get')

    def test_post(self):
        http.post('https://blazedemo.com/?tag=post')

    def test_put(self):
        http.put('https://blazedemo.com/?tag=put')

    def test_patch(self):
        http.patch('https://blazedemo.com/?tag=patch')

    def test_head(self):
        http.head('https://blazedemo.com/?tag=head')

    def test_delete(self):
        http.delete('https://blazedemo.com/?tag=delete')

    def test_options(self):
        http.options('https://blazedemo.com/echo.php?echo=options')


class TestTargetMethods(TestCase):
    def setUp(self):

# Path: apiritif/http.py
# class http(object):
#     log = log.getChild('http')
# 
#     @staticmethod
#     def target(*args, **kwargs):
#         return HTTPTarget(*args, **kwargs)
# 
#     @staticmethod
#     def request(method, address, session=None,
#                 params=None, headers=None, cookies=None, data=None, json=None, files=None,
#                 encrypted_cert=None, allow_redirects=True, timeout=30):
#         """
# 
#         :param method: str
#         :param address: str
#         :return: response
#         :rtype: HTTPResponse
#         """
#         http.log.info("Request: %s %s", method, address)
#         msg = "Request: params=%r, headers=%r, cookies=%r, data=%r, json=%r, files=%r, allow_redirects=%r, timeout=%r"
#         http.log.debug(msg, params, headers, cookies, data, json, files, allow_redirects, timeout)
# 
#         if headers is None:
#             headers = {}
#         if "User-Agent" not in headers:
#             headers["User-Agent"] = "Apiritif"
# 
#         if session is None:
#             session = requests.Session()
# 
#         if encrypted_cert is not None:
#             certificate_file_path, passphrase = encrypted_cert
#             adapter = SSLAdapter(certificate_file_path=certificate_file_path, passphrase=passphrase)
#             session.mount('https://', adapter)
# 
#         request = requests.Request(method, address,
#                                    params=params, headers=headers, cookies=cookies, json=json, data=data, files=files)
#         prepared = session.prepare_request(request)
#         settings = session.merge_environment_settings(prepared.url, {}, False, False, None)
#         try:
#             response = session.send(prepared, allow_redirects=allow_redirects, timeout=timeout, **settings)
#         except requests.exceptions.Timeout as exc:
#             recorder.record_http_request_failure(method, address, prepared, exc, session)
#             raise TimeoutError("Connection to %s timed out" % address)
#         except requests.exceptions.ConnectionError as exc:
#             recorder.record_http_request_failure(method, address, prepared, exc, session)
#             raise ConnectionError("Connection to %s failed" % address)
#         except BaseException as exc:
#             recorder.record_http_request_failure(method, address, prepared, exc, session)
#             raise
#         http.log.info("Response: %s %s", response.status_code, response.reason)
#         http.log.debug("Response headers: %r", response.headers)
#         http.log.debug("Response cookies: %r", {x: response.cookies.get(x) for x in response.cookies})
#         http.log.debug('Response content: \n%s', response.content)
#         wrapped_response = HTTPResponse(response)
#         recorder.record_http_request(method, address, prepared, wrapped_response, session)
#         return wrapped_response
# 
#     @staticmethod
#     def get(address, **kwargs):
#         return http.request("GET", address, **kwargs)
# 
#     @staticmethod
#     def post(address, **kwargs):
#         return http.request("POST", address, **kwargs)
# 
#     @staticmethod
#     def put(address, **kwargs):
#         return http.request("PUT", address, **kwargs)
# 
#     @staticmethod
#     def delete(address, **kwargs):
#         return http.request("DELETE", address, **kwargs)
# 
#     @staticmethod
#     def patch(address, **kwargs):
#         return http.request("PATCH", address, **kwargs)
# 
#     @staticmethod
#     def head(address, **kwargs):
#         return http.request("HEAD", address, **kwargs)
# 
#     @staticmethod
#     def options(address, **kwargs):
#         return http.request("OPTIONS", address, **kwargs)
# 
#     @staticmethod
#     def connect(address, **kwargs):
#         return http.request("CONNECT", address, **kwargs)


# Path: tests/unit/test_methods.py
from apiritif import http
from unittest import TestCase



class TestHTTPMethods(TestCase):
    def test_get(self):
        http.get('https://blazedemo.com/?tag=get')

    def test_post(self):
        http.post('https://blazedemo.com/?tag=post')

    def test_put(self):
        http.put('https://blazedemo.com/?tag=put')

    def test_patch(self):
        http.patch('https://blazedemo.com/?tag=patch')

    def test_head(self):
        http.head('https://blazedemo.com/?tag=head')

    def test_delete(self):
        http.delete('https://blazedemo.com/?tag=delete')

    def test_options(self):
        http.options('https://blazedemo.com/echo.php?echo=options')


class TestTargetMethods(TestCase):
    def setUp(self):

        self.target = http.target('https://blazedemo.com', auto_assert_ok=False)