# 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
    test.run(handle_connect, handle_command_update=handle_command_update)

    def handle_connect(handler):
        device_type_name = test.generate_id('dt-s-u-c', test.DEVICE_TYPE_ENTITY)
        description = '%s-description' % device_type_name
        device_type = handler.api.create_device_type(device_type_name,
                                                     description)
        device_type_1 = handler.api.get_device_type(device_type.id)
        device_type.remove()
        try:
            device_type_1.subscribe_update_commands()
            assert False
        except ApiResponseError as api_response_error:
            assert api_response_error.code == 404

    test.run(handle_connect)


def test_unsubscribe_update_commands(test):
    test.only_admin_implementation()

    def handle_connect(handler):
        name = test.generate_id('dt-u-u-c', test.DEVICE_TYPE_ENTITY)
        description = '%s-description' % name
        device_type = handler.api.create_device_type(name, description)
        subscription = device_type.subscribe_update_commands()
        subscription.remove()
        try:
            subscription.remove()
            assert False

# 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

    test.run(handle_connect, handle_command_update=handle_command_update)

    def handle_connect(handler):
        device_type_name = test.generate_id('dt-s-u-c', test.DEVICE_TYPE_ENTITY)
        description = '%s-description' % device_type_name
        device_type = handler.api.create_device_type(device_type_name,
                                                     description)
        device_type_1 = handler.api.get_device_type(device_type.id)
        device_type.remove()
        try:
            device_type_1.subscribe_update_commands()
            assert False
        except ApiResponseError as api_response_error:
            assert api_response_error.code == 404

    test.run(handle_connect)


def test_unsubscribe_update_commands(test):
    test.only_admin_implementation()

    def handle_connect(handler):
        name = test.generate_id('dt-u-u-c', test.DEVICE_TYPE_ENTITY)
        description = '%s-description' % name
        device_type = handler.api.create_device_type(name, description)
        subscription = device_type.subscribe_update_commands()
        subscription.remove()
        try:
            subscription.remove()
            assert False

        except SubscriptionError: