# Path: deepstreampy/message/message_builder.py
# def get_message(topic, action, data=None):
# def typed(value):
# 
# Path: deepstreampy/message/message_parser.py
# def parse(raw_messages, client):
# def _parse_message(message, client):
# def convert_typed(value, client):
# 
# Path: deepstreampy/constants/topic.py
# CONNECTION = 'C'
# AUTH = 'A'
# ERROR = 'X'
# EVENT = 'E'
# RECORD = 'R'
# RPC = 'P'
# PRESENCE = 'U'
# PRIVATE = 'PRIVATE/'
# 
# Path: deepstreampy/constants/actions.py
# PING = 'PI'
# PONG = 'PO'
# ACK = 'A'
# REDIRECT = 'RED'
# CHALLENGE = 'CH'
# CHALLENGE_RESPONSE = 'CHR'
# READ = 'R'
# CREATE = 'C'
# UPDATE = 'U'
# PATCH = 'P'
# DELETE = 'D'
# SUBSCRIBE = 'S'
# UNSUBSCRIBE = 'US'
# HAS = 'H'
# SNAPSHOT = 'SN'
# INVOKE = 'I'
# SUBSCRIPTION_FOR_PATTERN_FOUND = 'SP'
# SUBSCRIPTION_FOR_PATTERN_REMOVED = 'SR'
# SUBSCRIPTION_HAS_PROVIDER = 'SH'
# LISTEN = 'L'
# UNLISTEN = 'UL'
# LISTEN_ACCEPT = 'LA'
# LISTEN_REJECT = 'LR'
# PROVIDER_UPDATE = 'PU'
# QUERY = 'Q'
# CREATEORREAD = 'CR'
# EVENT = 'EVT'
# ERROR = 'E'
# REQUEST = 'REQ'
# RESPONSE = 'RES'
# REJECTION = 'REJ'
# PRESENCE_JOIN = 'PNJ'
# PRESENCE_LEAVE = 'PNL'
# QUERY = 'Q'
# WRITE_ACKNOWLEDGEMENT = 'WA'
# def reverse_lookup(action):
# 
# Path: deepstreampy/constants/types.py
# STRING = 'S'
# OBJECT = 'O'
# NUMBER = 'N'
# NULL = 'L'
# TRUE = 'T'
# FALSE = 'F'
# UNDEFINED = 'U'
# 
# Path: deepstreampy/constants/topic.py
# CONNECTION = 'C'
# AUTH = 'A'
# ERROR = 'X'
# EVENT = 'E'
# RECORD = 'R'
# RPC = 'P'
# PRESENCE = 'U'
# PRIVATE = 'PRIVATE/'
# 
# Path: deepstreampy/constants/event.py
# CONNECTION_ERROR = 'connectionError'
# CONNECTION_STATE_CHANGED = 'connectionStateChanged'
# MAX_RECONNECTION_ATTEMPTS_REACHED = 'MAX_RECONNECTION_ATTEMPTS_REACHED'
# CONNECTION_AUTHENTICATION_TIMEOUT = 'CONNECTION_AUTHENTICATION_TIMEOUT'
# ACK_TIMEOUT = 'ACK_TIMEOUT'
# NO_RPC_PROVIDER = 'NO_RPC_PROVIDER'
# RESPONSE_TIMEOUT = 'RESPONSE_TIMEOUT'
# DELETE_TIMEOUT = 'DELETE_TIMEOUT'
# UNSOLICITED_MESSAGE = 'UNSOLICITED_MESSAGE'
# MESSAGE_DENIED = 'MESSAGE_DENIED'
# MESSAGE_PARSE_ERROR = 'MESSAGE_PARSE_ERROR'
# VERSION_EXISTS = 'VERSION_EXISTS'
# NOT_AUTHENTICATED = 'NOT_AUTHENTICATED'
# MESSAGE_PERMISSION_ERROR = 'MESSAGE_PERMISSION_ERROR'
# LISTENER_EXISTS = 'LISTENER_EXISTS'
# NOT_LISTENING = 'NOT_LISTENING'
# TOO_MANY_AUTH_ATTEMPTS = 'TOO_MANY_AUTH_ATTEMPTS'
# IS_CLOSED = 'IS_CLOSED'
# RECORD_NOT_FOUND = 'RECORD_NOT_FOUND'
# NOT_SUBSCRIBED = 'NOT_SUBSCRIBED'
# INVALID_RPC_CORRELATION_ID = 'INVALID_RPC_CORRELATION_ID'
# 
# 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):


from deepstreampy.message import message_builder, message_parser
from deepstreampy.constants import topic, actions, types
from deepstreampy.constants import topic as topic_constants
from deepstreampy.constants import event as event_constants
from deepstreampy import client
import json
import unittest
            topic.AUTH + chr(31) + actions.REQUEST + chr(31) +
            json.dumps(data[0], separators=(',', ':')) + chr(30))
        self.assertEqual(real_message, expected_message)
        parsed_messages = message_parser.parse(real_message, self.client)
        self.assertEqual(len(parsed_messages), 1)
        message = parsed_messages[0]
        self.assertEqual(message['topic'], topic.AUTH)
        self.assertEqual(message['action'], actions.REQUEST)
        self.assertEqual([json.loads(message['data'][0])], data)
        data = ['entry1', 'entry2']
        real_message = message_builder.get_message(topic.EVENT,
                                                   actions.READ,
                                                   data)
        expected_message = (topic.EVENT + chr(31) +
                            actions.READ + chr(31) +
                            data[0] + chr(31) +
                            data[1] + chr(30))
        self.assertEqual(real_message, expected_message)

        parsed_messages = message_parser.parse(real_message, self.client)
        self.assertEqual(len(parsed_messages), 1)

        message = parsed_messages[0]
        self.assertEqual(message['topic'], topic.EVENT)
        self.assertEqual(message['action'], actions.READ)
        self.assertEqual(message['data'], data)

    def test_wrong_action(self):
        """Test parsing message with an action that doesn't exist."""
        self.assertRaises(ValueError,

# Path: deepstreampy/message/message_builder.py
# def get_message(topic, action, data=None):
# def typed(value):
# 
# Path: deepstreampy/message/message_parser.py
# def parse(raw_messages, client):
# def _parse_message(message, client):
# def convert_typed(value, client):
# 
# Path: deepstreampy/constants/topic.py
# CONNECTION = 'C'
# AUTH = 'A'
# ERROR = 'X'
# EVENT = 'E'
# RECORD = 'R'
# RPC = 'P'
# PRESENCE = 'U'
# PRIVATE = 'PRIVATE/'
# 
# Path: deepstreampy/constants/actions.py
# PING = 'PI'
# PONG = 'PO'
# ACK = 'A'
# REDIRECT = 'RED'
# CHALLENGE = 'CH'
# CHALLENGE_RESPONSE = 'CHR'
# READ = 'R'
# CREATE = 'C'
# UPDATE = 'U'
# PATCH = 'P'
# DELETE = 'D'
# SUBSCRIBE = 'S'
# UNSUBSCRIBE = 'US'
# HAS = 'H'
# SNAPSHOT = 'SN'
# INVOKE = 'I'
# SUBSCRIPTION_FOR_PATTERN_FOUND = 'SP'
# SUBSCRIPTION_FOR_PATTERN_REMOVED = 'SR'
# SUBSCRIPTION_HAS_PROVIDER = 'SH'
# LISTEN = 'L'
# UNLISTEN = 'UL'
# LISTEN_ACCEPT = 'LA'
# LISTEN_REJECT = 'LR'
# PROVIDER_UPDATE = 'PU'
# QUERY = 'Q'
# CREATEORREAD = 'CR'
# EVENT = 'EVT'
# ERROR = 'E'
# REQUEST = 'REQ'
# RESPONSE = 'RES'
# REJECTION = 'REJ'
# PRESENCE_JOIN = 'PNJ'
# PRESENCE_LEAVE = 'PNL'
# QUERY = 'Q'
# WRITE_ACKNOWLEDGEMENT = 'WA'
# def reverse_lookup(action):
# 
# Path: deepstreampy/constants/types.py
# STRING = 'S'
# OBJECT = 'O'
# NUMBER = 'N'
# NULL = 'L'
# TRUE = 'T'
# FALSE = 'F'
# UNDEFINED = 'U'
# 
# Path: deepstreampy/constants/topic.py
# CONNECTION = 'C'
# AUTH = 'A'
# ERROR = 'X'
# EVENT = 'E'
# RECORD = 'R'
# RPC = 'P'
# PRESENCE = 'U'
# PRIVATE = 'PRIVATE/'
# 
# Path: deepstreampy/constants/event.py
# CONNECTION_ERROR = 'connectionError'
# CONNECTION_STATE_CHANGED = 'connectionStateChanged'
# MAX_RECONNECTION_ATTEMPTS_REACHED = 'MAX_RECONNECTION_ATTEMPTS_REACHED'
# CONNECTION_AUTHENTICATION_TIMEOUT = 'CONNECTION_AUTHENTICATION_TIMEOUT'
# ACK_TIMEOUT = 'ACK_TIMEOUT'
# NO_RPC_PROVIDER = 'NO_RPC_PROVIDER'
# RESPONSE_TIMEOUT = 'RESPONSE_TIMEOUT'
# DELETE_TIMEOUT = 'DELETE_TIMEOUT'
# UNSOLICITED_MESSAGE = 'UNSOLICITED_MESSAGE'
# MESSAGE_DENIED = 'MESSAGE_DENIED'
# MESSAGE_PARSE_ERROR = 'MESSAGE_PARSE_ERROR'
# VERSION_EXISTS = 'VERSION_EXISTS'
# NOT_AUTHENTICATED = 'NOT_AUTHENTICATED'
# MESSAGE_PERMISSION_ERROR = 'MESSAGE_PERMISSION_ERROR'
# LISTENER_EXISTS = 'LISTENER_EXISTS'
# NOT_LISTENING = 'NOT_LISTENING'
# TOO_MANY_AUTH_ATTEMPTS = 'TOO_MANY_AUTH_ATTEMPTS'
# IS_CLOSED = 'IS_CLOSED'
# RECORD_NOT_FOUND = 'RECORD_NOT_FOUND'
# NOT_SUBSCRIBED = 'NOT_SUBSCRIBED'
# INVALID_RPC_CORRELATION_ID = 'INVALID_RPC_CORRELATION_ID'
# 
# 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/test_message.py
from deepstreampy.message import message_builder, message_parser
from deepstreampy.constants import topic, actions, types
from deepstreampy.constants import topic as topic_constants
from deepstreampy.constants import event as event_constants
from deepstreampy import client
import json
import unittest

            topic.AUTH + chr(31) + actions.REQUEST + chr(31) +
            json.dumps(data[0], separators=(',', ':')) + chr(30))
        self.assertEqual(real_message, expected_message)
        parsed_messages = message_parser.parse(real_message, self.client)
        self.assertEqual(len(parsed_messages), 1)
        message = parsed_messages[0]
        self.assertEqual(message['topic'], topic.AUTH)
        self.assertEqual(message['action'], actions.REQUEST)
        self.assertEqual([json.loads(message['data'][0])], data)
        data = ['entry1', 'entry2']
        real_message = message_builder.get_message(topic.EVENT,
                                                   actions.READ,
                                                   data)
        expected_message = (topic.EVENT + chr(31) +
                            actions.READ + chr(31) +
                            data[0] + chr(31) +
                            data[1] + chr(30))
        self.assertEqual(real_message, expected_message)

        parsed_messages = message_parser.parse(real_message, self.client)
        self.assertEqual(len(parsed_messages), 1)

        message = parsed_messages[0]
        self.assertEqual(message['topic'], topic.EVENT)
        self.assertEqual(message['action'], actions.READ)
        self.assertEqual(message['data'], data)

    def test_wrong_action(self):
        """Test parsing message with an action that doesn't exist."""
        self.assertRaises(ValueError,

                          message_parser.parse,