# Path: deepstreampy/client.py
# def connect(url, **options):
#     def __init__(self, url, **options):
#     def connect(self, callback=None):
#     def close(self):
#     def login(self, auth_params):
#     def _on_message(self, message):
#     def _on_error(self, topic, event, msg=None):
#     def connection_state(self):
#     def record(self):
#     def event(self):
#     def rpc(self):
#     def presence(self):
#     def io_loop(self):
# class Client(EventEmitter):
# 
# Path: deepstreampy/record.py
# class AnonymousRecord(EventEmitter, object):
#     def __init__(self, record_handler):
#         super(AnonymousRecord, self).__init__()
#         self._record_handler = record_handler
#         self._name = None
#         self._record = None
#         self._subscriptions = []
#         self._proxy_method('delete')
#         self._proxy_method('set')
#         self._proxy_method('discard')
# 
#     def get(self, path=None):
#         """
#         Proxies the actual record's get method.
# 
#         Args:
#             path (str, optional): a JSON path. If not provided, the entire
#                 record is returned
#         """
#         if self._record is None:
#             return None
# 
#         return self._record.get(path)
# 
#     def subscribe(self, callback, path=None):
#         """
#         Proxies the actual record's subscribe method.
# 
#         Args:
#             callback (callable):
#             path (str): a JSON path. If not provided, the subscription is for
#                 the entire record.
#         """
#         self._subscriptions.append((callback, path))
# 
#         if self._record is not None:
#             self._record.subscribe(callback, path, True)
# 
#     def unsubscribe(self, callback, path=None):
#         """
#         Proxies the actual record's unsubscribe method.
# 
#         Args:
#             callback (callable):
#             path (str): a JSON path. If not provided, the subscription is for
#                 the entire record.
#         """
#         self._subscriptions.remove((callback, path))
# 
#         if self._record is not None:
#             self._record.unsubscribe(callback, path)
# 
#     def _on_record_get(self, record):
#         self._record = record
# 
#     @property
#     def name(self):
#         return self._name
# 
#     @name.setter
#     @gen.coroutine
#     def name(self, value):
#         self._name = value
# 
#         if self._record is not None and not self._record.is_destroyed:
#             for subscription in self._subscriptions:
#                 self._record.unsubscribe(*subscription)
# 
#             self._record.discard()
# 
#         record_future = self._record_handler.get_record(value)
# 
#         self._record = yield record_future
# 
#         for subscription in self._subscriptions:
#             self._record.subscribe(*subscription, trigger_now=True)
# 
#         self._record.when_ready(partial(self.emit, "ready"))
#         self.emit("nameChanged", value)
# 
#     def _proxy_method(self, method_name):
#         method = partial(self._call_method_on_record, method_name)
#         setattr(self, method_name, method)
# 
#     def _call_method_on_record(self, method_name, *args, **kwargs):
#         if self._record is None:
#             raise AttributeError(
#                 "Can't invoke {}. AnonymousRecord not initialised. "
#                 "Set `name` first.")
# 
#         getattr(self._record, method_name)(*args, **kwargs)
# 
# Path: deepstreampy/constants/connection_state.py
# CLOSED = 'CLOSED'
# AWAITING_AUTHENTICATION = 'AWAITING_AUTHENTICATION'
# AWAITING_CONNECTION = 'AWAITING_CONNECTION'
# AUTHENTICATING = 'AUTHENTICATING'
# OPEN = 'OPEN'
# ERROR = 'ERROR'
# RECONNECTING = 'RECONNECTING'
# CHALLENGING = 'CHALLENGING'


from deepstreampy import client
from deepstreampy.record import AnonymousRecord
from deepstreampy.constants import connection_state
from tornado import testing
from tornado.concurrent import Future
    from unittest import mock
import sys
    import mock
from __future__ import absolute_import, division, print_function, with_statement
from __future__ import unicode_literals




if sys.version_info[0] < 3:
else:

URL = "ws://localhost:7777/deepstream"


class AnonymousRecordTest(testing.AsyncTestCase):

    def setUp(self):
        super(AnonymousRecordTest, self).setUp()

# Path: deepstreampy/client.py
# def connect(url, **options):
#     def __init__(self, url, **options):
#     def connect(self, callback=None):
#     def close(self):
#     def login(self, auth_params):
#     def _on_message(self, message):
#     def _on_error(self, topic, event, msg=None):
#     def connection_state(self):
#     def record(self):
#     def event(self):
#     def rpc(self):
#     def presence(self):
#     def io_loop(self):
# class Client(EventEmitter):
# 
# Path: deepstreampy/record.py
# class AnonymousRecord(EventEmitter, object):
#     def __init__(self, record_handler):
#         super(AnonymousRecord, self).__init__()
#         self._record_handler = record_handler
#         self._name = None
#         self._record = None
#         self._subscriptions = []
#         self._proxy_method('delete')
#         self._proxy_method('set')
#         self._proxy_method('discard')
# 
#     def get(self, path=None):
#         """
#         Proxies the actual record's get method.
# 
#         Args:
#             path (str, optional): a JSON path. If not provided, the entire
#                 record is returned
#         """
#         if self._record is None:
#             return None
# 
#         return self._record.get(path)
# 
#     def subscribe(self, callback, path=None):
#         """
#         Proxies the actual record's subscribe method.
# 
#         Args:
#             callback (callable):
#             path (str): a JSON path. If not provided, the subscription is for
#                 the entire record.
#         """
#         self._subscriptions.append((callback, path))
# 
#         if self._record is not None:
#             self._record.subscribe(callback, path, True)
# 
#     def unsubscribe(self, callback, path=None):
#         """
#         Proxies the actual record's unsubscribe method.
# 
#         Args:
#             callback (callable):
#             path (str): a JSON path. If not provided, the subscription is for
#                 the entire record.
#         """
#         self._subscriptions.remove((callback, path))
# 
#         if self._record is not None:
#             self._record.unsubscribe(callback, path)
# 
#     def _on_record_get(self, record):
#         self._record = record
# 
#     @property
#     def name(self):
#         return self._name
# 
#     @name.setter
#     @gen.coroutine
#     def name(self, value):
#         self._name = value
# 
#         if self._record is not None and not self._record.is_destroyed:
#             for subscription in self._subscriptions:
#                 self._record.unsubscribe(*subscription)
# 
#             self._record.discard()
# 
#         record_future = self._record_handler.get_record(value)
# 
#         self._record = yield record_future
# 
#         for subscription in self._subscriptions:
#             self._record.subscribe(*subscription, trigger_now=True)
# 
#         self._record.when_ready(partial(self.emit, "ready"))
#         self.emit("nameChanged", value)
# 
#     def _proxy_method(self, method_name):
#         method = partial(self._call_method_on_record, method_name)
#         setattr(self, method_name, method)
# 
#     def _call_method_on_record(self, method_name, *args, **kwargs):
#         if self._record is None:
#             raise AttributeError(
#                 "Can't invoke {}. AnonymousRecord not initialised. "
#                 "Set `name` first.")
# 
#         getattr(self._record, method_name)(*args, **kwargs)
# 
# Path: deepstreampy/constants/connection_state.py
# CLOSED = 'CLOSED'
# AWAITING_AUTHENTICATION = 'AWAITING_AUTHENTICATION'
# AWAITING_CONNECTION = 'AWAITING_CONNECTION'
# AUTHENTICATING = 'AUTHENTICATING'
# OPEN = 'OPEN'
# ERROR = 'ERROR'
# RECONNECTING = 'RECONNECTING'
# CHALLENGING = 'CHALLENGING'


# Path: tests/record_tests/test_anonymous_record.py
from deepstreampy import client
from deepstreampy.record import AnonymousRecord
from deepstreampy.constants import connection_state
from tornado import testing
from tornado.concurrent import Future
    from unittest import mock
import sys
    import mock

from __future__ import absolute_import, division, print_function, with_statement
from __future__ import unicode_literals




if sys.version_info[0] < 3:
else:

URL = "ws://localhost:7777/deepstream"


class AnonymousRecordTest(testing.AsyncTestCase):

    def setUp(self):
        super(AnonymousRecordTest, self).setUp()

        self.client = client.Client(URL)