# Path: devicehive/device.py
# class DeviceError(ApiRequestError):
#     """Device error."""
# 
# Path: devicehive/subscription.py
# class SubscriptionError(ApiRequestError):
#     """Subscription error."""
# 
# 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


from devicehive import DeviceError, SubscriptionError
from devicehive import ApiResponseError
    def handle_notification(handler, notification):
        assert notification.id in handler.data['notification_ids']
        handler.data['notification_ids'].remove(notification.id)
        if handler.data['notification_ids']:
            return
        handler.data['subscription'].remove()
        handler.data['device'].remove()
        handler.disconnect()

    test.run(handle_connect, handle_notification=handle_notification)

    def handle_connect(handler):
        device, notification_names, notification_ids = init_data(handler)
        notification_name = notification_names[:1]
        set_handler_data(handler, device, notification_names, notification_ids)
        send_data(handler, device, notification_name)
        handler.data['subscription'] = device.subscribe_notifications(
            names=notification_name)

    def handle_notification(handler, notification):
        assert notification.id == handler.data['notification_ids'][0]
        handler.data['subscription'].remove()
        handler.data['device'].remove()
        handler.disconnect()

    test.run(handle_connect, handle_notification=handle_notification)

    def handle_connect(handler):
        device, notification_names, notification_ids = init_data(handler)


# Path: devicehive/device.py
# class DeviceError(ApiRequestError):
#     """Device error."""
# 
# Path: devicehive/subscription.py
# class SubscriptionError(ApiRequestError):
#     """Subscription error."""
# 
# 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: tests/test_api_device.py
from devicehive import DeviceError, SubscriptionError
from devicehive import ApiResponseError

    def handle_notification(handler, notification):
        assert notification.id in handler.data['notification_ids']
        handler.data['notification_ids'].remove(notification.id)
        if handler.data['notification_ids']:
            return
        handler.data['subscription'].remove()
        handler.data['device'].remove()
        handler.disconnect()

    test.run(handle_connect, handle_notification=handle_notification)

    def handle_connect(handler):
        device, notification_names, notification_ids = init_data(handler)
        notification_name = notification_names[:1]
        set_handler_data(handler, device, notification_names, notification_ids)
        send_data(handler, device, notification_name)
        handler.data['subscription'] = device.subscribe_notifications(
            names=notification_name)

    def handle_notification(handler, notification):
        assert notification.id == handler.data['notification_ids'][0]
        handler.data['subscription'].remove()
        handler.data['device'].remove()
        handler.disconnect()

    test.run(handle_connect, handle_notification=handle_notification)

    def handle_connect(handler):
        device, notification_names, notification_ids = init_data(handler)


        device_1 = handler.api.get_device(device.id)