# 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 unittest import mock
import unittest
import sys
    import mock
                                  'data': ['b/.*', 'b/1']})

        self.handler.write_message.assert_called_with(msg('E|LR|b/.*|b/1+'))

    def test_accept_and_discard(self):
        def listen_callback(data, is_subscribed, response=None):
            if is_subscribed:
                response.accept()

                self.client.event.handle({'topic': 'E',
                                          'action': 'SR',
                                          'data': ['b/.*', 'b/2']})

        self.client.event.listen('b/.*', listen_callback)
        self.client.event.handle({'topic': 'E',
                                  'action': 'SP',
                                  'data': ['b/.*', 'b/2']})

        self.handler.write_message.assert_called_with(msg('E|LA|b/.*|b/2+'))

    def test_accept_unlisten(self):

        def listen_callback(data, is_subscribed, response):
            response.accept()

        self.client.event.listen('a/.*', listen_callback)
        self.client.event.handle({'topic': 'E',
                                  'action': 'SP',
                                  'data': ['a/.*', 'a/1']})


# 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_event.py
from deepstreampy.constants import connection_state
from deepstreampy import client
from tests.util import msg
    from unittest import mock
import unittest
import sys
    import mock

                                  'data': ['b/.*', 'b/1']})

        self.handler.write_message.assert_called_with(msg('E|LR|b/.*|b/1+'))

    def test_accept_and_discard(self):
        def listen_callback(data, is_subscribed, response=None):
            if is_subscribed:
                response.accept()

                self.client.event.handle({'topic': 'E',
                                          'action': 'SR',
                                          'data': ['b/.*', 'b/2']})

        self.client.event.listen('b/.*', listen_callback)
        self.client.event.handle({'topic': 'E',
                                  'action': 'SP',
                                  'data': ['b/.*', 'b/2']})

        self.handler.write_message.assert_called_with(msg('E|LA|b/.*|b/2+'))

    def test_accept_unlisten(self):

        def listen_callback(data, is_subscribed, response):
            response.accept()

        self.client.event.listen('a/.*', listen_callback)
        self.client.event.handle({'topic': 'E',
                                  'action': 'SP',
                                  'data': ['a/.*', 'a/1']})


        self.handler.write_message.assert_called_with(msg('E|LA|a/.*|a/1+'))