# Path: launchkey/transports/base.py
# class APIResponse(object):
#     """ Response from API """
#     data = None
#     headers = None
#     status_code = None
#     reason = None
# 
#     def __init__(self, data, headers, status_code, reason=None, raw_data=None):
#         self.data = data
#         self.headers = headers
#         self.status_code = status_code
#         self.reason = reason
#         self.raw_data = raw_data
# 
#     def __str__(self):
#         return super().__str__() + ": %s %s %s" % (
#             self.status_code, self.reason, self.data)
# 
# class APIErrorResponse(APIResponse):
#     """Response that should be raised when an OK status is not found"""


import unittest
from mock import MagicMock, ANY
from launchkey.transports.base import APIResponse, APIErrorResponse


class TestAPIResponses(unittest.TestCase):

    def test_api_response_success(self):
        data = MagicMock(spec=str)
        headers = MagicMock(spec=dict)
        status_code = MagicMock(spec=int)
        response = APIResponse(data, headers, status_code)
        self.assertEqual(response.data, data)
        self.assertEqual(response.headers, headers)
        self.assertEqual(response.status_code, status_code)

    def test_api_response_string_repr(self):
        data = MagicMock(spec=str)
        headers = MagicMock(spec=dict)
        status_code = MagicMock(spec=int)
        response = APIResponse(data, headers, status_code)
        self.assertIn(str(data), str(response))
        self.assertIn(str(status_code), str(response))

    def test_error_response_type(self):

# Path: launchkey/transports/base.py
# class APIResponse(object):
#     """ Response from API """
#     data = None
#     headers = None
#     status_code = None
#     reason = None
# 
#     def __init__(self, data, headers, status_code, reason=None, raw_data=None):
#         self.data = data
#         self.headers = headers
#         self.status_code = status_code
#         self.reason = reason
#         self.raw_data = raw_data
# 
#     def __str__(self):
#         return super().__str__() + ": %s %s %s" % (
#             self.status_code, self.reason, self.data)
# 
# class APIErrorResponse(APIResponse):
#     """Response that should be raised when an OK status is not found"""


# Path: tests/test_base_transport.py
import unittest
from mock import MagicMock, ANY
from launchkey.transports.base import APIResponse, APIErrorResponse



class TestAPIResponses(unittest.TestCase):

    def test_api_response_success(self):
        data = MagicMock(spec=str)
        headers = MagicMock(spec=dict)
        status_code = MagicMock(spec=int)
        response = APIResponse(data, headers, status_code)
        self.assertEqual(response.data, data)
        self.assertEqual(response.headers, headers)
        self.assertEqual(response.status_code, status_code)

    def test_api_response_string_repr(self):
        data = MagicMock(spec=str)
        headers = MagicMock(spec=dict)
        status_code = MagicMock(spec=int)
        response = APIResponse(data, headers, status_code)
        self.assertIn(str(data), str(response))
        self.assertIn(str(status_code), str(response))

    def test_error_response_type(self):

        self.assertIsInstance(APIErrorResponse(ANY, ANY, ANY), APIResponse)