# 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: 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: tests/util.py
# def msg(value):
#     return value.replace("|", chr(31)).replace("+", chr(30)).encode()


from deepstreampy.constants import connection_state
from deepstreampy import client
from tests.util import msg
from tornado import testing
    from unittest import mock
import sys
    import mock
                                      'data': ['Homer']})
        callback.assert_called_with('Homer', True)
        self.wait()

        # Client logs out
        self.client.presence.handle({'topic': 'U',
                                      'action': 'PNL',
                                      'data': ['Marge']})
        callback.assert_called_with('Marge', False)
        callback.reset_mock()
        self.wait()

        # Query for clients
        f = self.client.presence.get_all()
        f.add_done_callback(callback)
        self.handler.write_message.assert_called_with(msg('U|Q|Q+'))

        # Receive data for query
        self.client.presence.handle({'topic': 'U',
                                      'action': 'Q',
                                      'data': ['Marge', 'Homer', 'Bart']})

        self.wait()

        callback.assert_called_with(f)
        self.assertEquals(f.result(), ['Marge', 'Homer', 'Bart'])


        # Unsubscribe to client logins
        self.client.presence.unsubscribe(callback)

# 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: 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: tests/util.py
# def msg(value):
#     return value.replace("|", chr(31)).replace("+", chr(30)).encode()


# Path: tests/test_presence.py
from deepstreampy.constants import connection_state
from deepstreampy import client
from tests.util import msg
from tornado import testing
    from unittest import mock
import sys
    import mock

                                      'data': ['Homer']})
        callback.assert_called_with('Homer', True)
        self.wait()

        # Client logs out
        self.client.presence.handle({'topic': 'U',
                                      'action': 'PNL',
                                      'data': ['Marge']})
        callback.assert_called_with('Marge', False)
        callback.reset_mock()
        self.wait()

        # Query for clients
        f = self.client.presence.get_all()
        f.add_done_callback(callback)
        self.handler.write_message.assert_called_with(msg('U|Q|Q+'))

        # Receive data for query
        self.client.presence.handle({'topic': 'U',
                                      'action': 'Q',
                                      'data': ['Marge', 'Homer', 'Bart']})

        self.wait()

        callback.assert_called_with(f)
        self.assertEquals(f.result(), ['Marge', 'Homer', 'Bart'])


        # Unsubscribe to client logins
        self.client.presence.unsubscribe(callback)

        self.handler.write_message.assert_called_with(msg('U|US+'))