# Path: moira_client/client.py
# class Client:
#     def __init__(self, api_url, auth_custom=None, auth_user=None, auth_pass=None, login=None):
#         """
# 
#         :param api_url: str Moira API URL
#         :param auth_custom: dict auth custom headers
#         :param auth_user: str auth user
#         :param auth_pass: str auth password
#         :param login: str auth login
#         """
#         if not api_url.endswith('/'):
#             self.api_url = api_url + '/'
#         else:
#             self.api_url = api_url
# 
#         if not login and auth_user:
#             login = auth_user
# 
#         self.auth = None
#         self.headers = {
#             'X-Webauth-User': login,
#             'Content-Type': 'application/json',
#             'User-Agent': 'Python Moira Client'
#             }
# 
#         if auth_user and auth_pass:
#             self.auth = HTTPBasicAuth(auth_user, auth_pass)
# 
#         if auth_custom:
#             self.headers.update(auth_custom)
# 
#     def get(self, path='', **kwargs):
#         """
# 
#         :param path: str api path
#         :param kwargs: additional parameters for request
#         :return: dict response
# 
#         :raises: HTTPError
#         :raises: InvalidJSONError
#         """
#         r = requests.get(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
#         r.raise_for_status()
#         try:
#             return r.json()
#         except ValueError:
#             raise InvalidJSONError(r.content)
# 
#     def delete(self, path='', **kwargs):
#         """
# 
#         :param path: str api path
#         :param kwargs: additional parameters for request
#         :return: dict response
# 
#         :raises: HTTPError
#         :raises: InvalidJSONError
#         """
#         r = requests.delete(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
#         r.raise_for_status()
#         try:
#             return r.json()
#         except ValueError:
#             raise InvalidJSONError(r.content)
# 
#     def put(self, path='', **kwargs):
#         """
# 
#         :param path: str api path
#         :param kwargs: additional parameters for request
#         :return: dict response
# 
#         :raises: HTTPError
#         :raises: InvalidJSONError
#         """
#         r = requests.put(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
#         r.raise_for_status()
#         try:
#             return r.json()
#         except ValueError:
#             raise InvalidJSONError(r.content)
# 
#     def post(self, path='', **kwargs):
#         """
# 
#         :param path: str api path
#         :param kwargs: additional parameters for request
#         :return: dict response
# 
#         :raises: HTTPError
#         :raises: InvalidJSONError
#         """
#         r = requests.post(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
#         r.raise_for_status()
#         try:
#             return r.json()
#         except ValueError:
#             raise InvalidJSONError(r.content)
# 
#     def _path_join(self, *args):
#         path = self.api_url
#         for part in args:
#             path += part
#         return path
# 
# Path: moira_client/client.py
# class InvalidJSONError(Exception):
#     def __init__(self, content):
#         """
# 
#         :param content: bytes response content
#         """
#         self.content = content


import unittest
import requests
    from unittest.mock import patch
    from mock import patch
from moira_client.client import Client
from moira_client.client import InvalidJSONError
    def test_get_invalid_response(self):

        def get(url, params, **kwargs):
            return FakeResponse()

        response = FakeResponse()

        with patch.object(requests, 'get', side_effects=get, return_value=response) as mock_get:
            test_path = 'test_path'

            client = Client(TEST_API_URL, TEST_HEADERS)
            with self.assertRaises(InvalidJSONError):
                client.get(test_path)

        self.assertTrue(mock_get.called)
        expected_url_call = TEST_API_URL + '/' + test_path
        mock_get.assert_called_with(expected_url_call, headers=TEST_HEADERS, auth=None)

    def test_put_invalid_response(self):
        test_data = {'test': 'test'}

        def put(url, data, **kwargs):
            return FakeResponse()

        response = FakeResponse()

        with patch.object(requests, 'put', side_effects=put, return_value=response) as mock_put:
            test_path = 'test_path'

            client = Client(TEST_API_URL, TEST_HEADERS)

# Path: moira_client/client.py
# class Client:
#     def __init__(self, api_url, auth_custom=None, auth_user=None, auth_pass=None, login=None):
#         """
# 
#         :param api_url: str Moira API URL
#         :param auth_custom: dict auth custom headers
#         :param auth_user: str auth user
#         :param auth_pass: str auth password
#         :param login: str auth login
#         """
#         if not api_url.endswith('/'):
#             self.api_url = api_url + '/'
#         else:
#             self.api_url = api_url
# 
#         if not login and auth_user:
#             login = auth_user
# 
#         self.auth = None
#         self.headers = {
#             'X-Webauth-User': login,
#             'Content-Type': 'application/json',
#             'User-Agent': 'Python Moira Client'
#             }
# 
#         if auth_user and auth_pass:
#             self.auth = HTTPBasicAuth(auth_user, auth_pass)
# 
#         if auth_custom:
#             self.headers.update(auth_custom)
# 
#     def get(self, path='', **kwargs):
#         """
# 
#         :param path: str api path
#         :param kwargs: additional parameters for request
#         :return: dict response
# 
#         :raises: HTTPError
#         :raises: InvalidJSONError
#         """
#         r = requests.get(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
#         r.raise_for_status()
#         try:
#             return r.json()
#         except ValueError:
#             raise InvalidJSONError(r.content)
# 
#     def delete(self, path='', **kwargs):
#         """
# 
#         :param path: str api path
#         :param kwargs: additional parameters for request
#         :return: dict response
# 
#         :raises: HTTPError
#         :raises: InvalidJSONError
#         """
#         r = requests.delete(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
#         r.raise_for_status()
#         try:
#             return r.json()
#         except ValueError:
#             raise InvalidJSONError(r.content)
# 
#     def put(self, path='', **kwargs):
#         """
# 
#         :param path: str api path
#         :param kwargs: additional parameters for request
#         :return: dict response
# 
#         :raises: HTTPError
#         :raises: InvalidJSONError
#         """
#         r = requests.put(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
#         r.raise_for_status()
#         try:
#             return r.json()
#         except ValueError:
#             raise InvalidJSONError(r.content)
# 
#     def post(self, path='', **kwargs):
#         """
# 
#         :param path: str api path
#         :param kwargs: additional parameters for request
#         :return: dict response
# 
#         :raises: HTTPError
#         :raises: InvalidJSONError
#         """
#         r = requests.post(self._path_join(path), headers=self.headers, auth=self.auth, **kwargs)
#         r.raise_for_status()
#         try:
#             return r.json()
#         except ValueError:
#             raise InvalidJSONError(r.content)
# 
#     def _path_join(self, *args):
#         path = self.api_url
#         for part in args:
#             path += part
#         return path
# 
# Path: moira_client/client.py
# class InvalidJSONError(Exception):
#     def __init__(self, content):
#         """
# 
#         :param content: bytes response content
#         """
#         self.content = content


# Path: tests/test_client.py
import unittest
import requests
    from unittest.mock import patch
    from mock import patch
from moira_client.client import Client
from moira_client.client import InvalidJSONError

    def test_get_invalid_response(self):

        def get(url, params, **kwargs):
            return FakeResponse()

        response = FakeResponse()

        with patch.object(requests, 'get', side_effects=get, return_value=response) as mock_get:
            test_path = 'test_path'

            client = Client(TEST_API_URL, TEST_HEADERS)
            with self.assertRaises(InvalidJSONError):
                client.get(test_path)

        self.assertTrue(mock_get.called)
        expected_url_call = TEST_API_URL + '/' + test_path
        mock_get.assert_called_with(expected_url_call, headers=TEST_HEADERS, auth=None)

    def test_put_invalid_response(self):
        test_data = {'test': 'test'}

        def put(url, data, **kwargs):
            return FakeResponse()

        response = FakeResponse()

        with patch.object(requests, 'put', side_effects=put, return_value=response) as mock_put:
            test_path = 'test_path'

            client = Client(TEST_API_URL, TEST_HEADERS)

            with self.assertRaises(InvalidJSONError):