# Path: gnsq/protocol.py
# MAGIC_V2 = b'  V2'
# NEWLINE = b'\n'
# SPACE = b' '
# EMPTY = b''
# HEARTBEAT = b'_heartbeat_'
# OK = b'OK'
# IDENTIFY = b'IDENTIFY'
# AUTH = b'AUTH'
# SUB = b'SUB'
# PUB = b'PUB'
# MPUB = b'MPUB'
# DPUB = b'DPUB'
# RDY = b'RDY'
# FIN = b'FIN'
# REQ = b'REQ'
# TOUCH = b'TOUCH'
# CLS = b'CLS'
# NOP = b'NOP'
# FRAME_TYPE_RESPONSE = 0
# FRAME_TYPE_ERROR = 1
# FRAME_TYPE_MESSAGE = 2
# VALID_NAME_RE = re.compile(r'^[\.a-zA-Z0-9_-]+(#ephemeral)?$')
# def _valid_name(name):
# def valid_topic_name(topic):
# def valid_channel_name(channel):
# def assert_valid_topic_name(topic):
# def assert_valid_channel_name(channel):
# def unpack_size(data):
# def unpack_response(data):
# def unpack_message(data):
# def _packsize(data):
# def _packbody(body):
# def _encode_param(data):
# def _command(cmd, body, *params):
# def identify(data):
# def auth(secret):
# def subscribe(topic_name, channel_name):
# def publish(topic_name, data):
# def multipublish_body(messages):
# def multipublish(topic_name, messages):
# def deferpublish(topic_name, data, delay_ms):
# def ready(count):
# def finish(message_id):
# def requeue(message_id, timeout=0):
# def touch(message_id):
# def close():
# def nop():


import json
import struct
import pytest
import six
from gnsq import protocol as nsq
        b'FIN test\n'),
    ('finish',
        {'message_id': u'\u2020est \xfcn\xee\xe7\xf8\u2202\xe9'},
        b'FIN \xe2\x80\xa0est \xc3\xbcn\xc3\xae\xc3\xa7\xc3\xb8\xe2\x88\x82\xc3\xa9\n'),
    ('requeue',
        {'message_id': 'test'},
        b'REQ test 0\n'),
    ('requeue',
        {'message_id': 'test', 'timeout': 60},
        b'REQ test 60\n'),
    ('touch',
        {'message_id': 'test'},
        b'TOUCH test\n'),
    ('ready',
        {'count': 100},
        b'RDY 100\n'),
    ('nop',
        {},
        b'NOP\n'),
    ('publish',
        {'topic_name': 'test', 'data': MSGS[0]},
        b'PUB test\n' + struct.pack('>l', len(MSGS[0])) + MSGS[0]),
    ('multipublish',
        {'topic_name': 'test', 'messages': MSGS},
        b'MPUB test\n' + struct.pack('>l', len(MPUB_BODY)) + MPUB_BODY),
    ('deferpublish',
        {'topic_name': 'test', 'data': MSGS[0], 'delay_ms': 42},
        b'DPUB test 42\n' + struct.pack('>l', len(MSGS[0])) + MSGS[0]),
])
def test_command(cmd_method, kwargs, result):

# Path: gnsq/protocol.py
# MAGIC_V2 = b'  V2'
# NEWLINE = b'\n'
# SPACE = b' '
# EMPTY = b''
# HEARTBEAT = b'_heartbeat_'
# OK = b'OK'
# IDENTIFY = b'IDENTIFY'
# AUTH = b'AUTH'
# SUB = b'SUB'
# PUB = b'PUB'
# MPUB = b'MPUB'
# DPUB = b'DPUB'
# RDY = b'RDY'
# FIN = b'FIN'
# REQ = b'REQ'
# TOUCH = b'TOUCH'
# CLS = b'CLS'
# NOP = b'NOP'
# FRAME_TYPE_RESPONSE = 0
# FRAME_TYPE_ERROR = 1
# FRAME_TYPE_MESSAGE = 2
# VALID_NAME_RE = re.compile(r'^[\.a-zA-Z0-9_-]+(#ephemeral)?$')
# def _valid_name(name):
# def valid_topic_name(topic):
# def valid_channel_name(channel):
# def assert_valid_topic_name(topic):
# def assert_valid_channel_name(channel):
# def unpack_size(data):
# def unpack_response(data):
# def unpack_message(data):
# def _packsize(data):
# def _packbody(body):
# def _encode_param(data):
# def _command(cmd, body, *params):
# def identify(data):
# def auth(secret):
# def subscribe(topic_name, channel_name):
# def publish(topic_name, data):
# def multipublish_body(messages):
# def multipublish(topic_name, messages):
# def deferpublish(topic_name, data, delay_ms):
# def ready(count):
# def finish(message_id):
# def requeue(message_id, timeout=0):
# def touch(message_id):
# def close():
# def nop():


# Path: tests/test_command.py
import json
import struct
import pytest
import six
from gnsq import protocol as nsq

        b'FIN test\n'),
    ('finish',
        {'message_id': u'\u2020est \xfcn\xee\xe7\xf8\u2202\xe9'},
        b'FIN \xe2\x80\xa0est \xc3\xbcn\xc3\xae\xc3\xa7\xc3\xb8\xe2\x88\x82\xc3\xa9\n'),
    ('requeue',
        {'message_id': 'test'},
        b'REQ test 0\n'),
    ('requeue',
        {'message_id': 'test', 'timeout': 60},
        b'REQ test 60\n'),
    ('touch',
        {'message_id': 'test'},
        b'TOUCH test\n'),
    ('ready',
        {'count': 100},
        b'RDY 100\n'),
    ('nop',
        {},
        b'NOP\n'),
    ('publish',
        {'topic_name': 'test', 'data': MSGS[0]},
        b'PUB test\n' + struct.pack('>l', len(MSGS[0])) + MSGS[0]),
    ('multipublish',
        {'topic_name': 'test', 'messages': MSGS},
        b'MPUB test\n' + struct.pack('>l', len(MPUB_BODY)) + MPUB_BODY),
    ('deferpublish',
        {'topic_name': 'test', 'data': MSGS[0], 'delay_ms': 42},
        b'DPUB test 42\n' + struct.pack('>l', len(MSGS[0])) + MSGS[0]),
])
def test_command(cmd_method, kwargs, result):

    assert getattr(nsq, cmd_method)(**kwargs) == result