# Path: devicehive/api_response.py
# class ApiResponseError(TransportError):
#     """Api response error."""
# 
#     def __init__(self, message, transport_name, code, error):
#         message = '%s Transport: %s. Code: %s. Error: %s' % (message,
#                                                              transport_name,
#                                                              code, error)
#         super(ApiResponseError, self).__init__(message)
#         self._transport_name = transport_name
#         self._code = code
#         self._error = error
# 
#     @property
#     def transport_name(self):
#         return self._transport_name
# 
#     @property
#     def code(self):
#         return self._code
# 
#     @property
#     def error(self):
#         return self._error
# 
# Path: devicehive/device_type.py
# class DeviceTypeError(ApiRequestError):
#     """DeviceType error."""
# 
# Path: devicehive/subscription.py
# class SubscriptionError(ApiRequestError):
#     """Subscription error."""


from devicehive import DeviceTypeError, ApiResponseError, SubscriptionError
        device_type = handler.api.create_device_type(device_type_name,
                                                     description)
        command_names = ['%s-name-%s' % (device_id, i) for i in range(2)]
        device = handler.api.put_device(device_id,
                                        device_type_id=device_type.id)
        return device, device_type, command_names, []

    def send_data(handler, device, command_names):
        for command_name in command_names:
            command = device.send_command(command_name)
            handler.data['command_ids'].append(command.id)

    def set_handler_data(handler, device, device_type, command_names,
                         command_ids):
        handler.data['device'] = device
        handler.data['device_type'] = device_type
        handler.data['command_names'] = command_names
        handler.data['command_ids'] = command_ids

    def handle_connect(handler):
        device, device_type, command_names, command_ids = init_data(handler)
        set_handler_data(handler, device, device_type, command_names,
                         command_ids)
        send_data(handler, device, command_names)
        handler.data['subscription'] = device_type.subscribe_insert_commands()

    def handle_command_insert(handler, command):
        assert command.id in handler.data['command_ids']
        handler.data['command_ids'].remove(command.id)
        if handler.data['command_ids']:

# Path: devicehive/api_response.py
# class ApiResponseError(TransportError):
#     """Api response error."""
# 
#     def __init__(self, message, transport_name, code, error):
#         message = '%s Transport: %s. Code: %s. Error: %s' % (message,
#                                                              transport_name,
#                                                              code, error)
#         super(ApiResponseError, self).__init__(message)
#         self._transport_name = transport_name
#         self._code = code
#         self._error = error
# 
#     @property
#     def transport_name(self):
#         return self._transport_name
# 
#     @property
#     def code(self):
#         return self._code
# 
#     @property
#     def error(self):
#         return self._error
# 
# Path: devicehive/device_type.py
# class DeviceTypeError(ApiRequestError):
#     """DeviceType error."""
# 
# Path: devicehive/subscription.py
# class SubscriptionError(ApiRequestError):
#     """Subscription error."""


# Path: tests/test_api_device_type.py
from devicehive import DeviceTypeError, ApiResponseError, SubscriptionError

        device_type = handler.api.create_device_type(device_type_name,
                                                     description)
        command_names = ['%s-name-%s' % (device_id, i) for i in range(2)]
        device = handler.api.put_device(device_id,
                                        device_type_id=device_type.id)
        return device, device_type, command_names, []

    def send_data(handler, device, command_names):
        for command_name in command_names:
            command = device.send_command(command_name)
            handler.data['command_ids'].append(command.id)

    def set_handler_data(handler, device, device_type, command_names,
                         command_ids):
        handler.data['device'] = device
        handler.data['device_type'] = device_type
        handler.data['command_names'] = command_names
        handler.data['command_ids'] = command_ids

    def handle_connect(handler):
        device, device_type, command_names, command_ids = init_data(handler)
        set_handler_data(handler, device, device_type, command_names,
                         command_ids)
        send_data(handler, device, command_names)
        handler.data['subscription'] = device_type.subscribe_insert_commands()

    def handle_command_insert(handler, command):
        assert command.id in handler.data['command_ids']
        handler.data['command_ids'].remove(command.id)
        if handler.data['command_ids']:

            return