def handle(socket, address): assert socket.recv(4) == ' V2' assert socket.recv(9) == 'IDENTIFY\n' size = nsq.unpack_size(socket.recv(4)) data = json.loads(socket.recv(size)) assert 'gnsq' in data['user_agent'] resp = json.dumps({'auth_required': True}) socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, resp)) assert socket.recv(5) == 'AUTH\n' assert nsq.unpack_size(socket.recv(4)) == 6 assert socket.recv(6) == 'secret' resp = json.dumps({'identity': 'awesome'}) socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, resp))
def handle(socket, address): assert socket.recv(4) == b' V2' assert socket.recv(9) == b'IDENTIFY\n' size = nsq.unpack_size(socket.recv(4)) data = json.loads(socket.recv(size).decode('utf-8')) assert 'gnsq' in data['user_agent'] resp = six.b(json.dumps({'auth_required': True})) socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, resp)) assert socket.recv(5) == b'AUTH\n' assert nsq.unpack_size(socket.recv(4)) == 6 assert socket.recv(6) == b'secret' resp = six.b(json.dumps({'identity': 'awesome'})) socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, resp))
def handle(socket, address): assert socket.recv(4) == b' V2' assert socket.recv(5) == b'AUTH\n' assert nsq.unpack_size(socket.recv(4)) == 6 assert socket.recv(6) == b'secret' resp = six.b(json.dumps({'identity': 'awesome'})) socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, resp))
def handle(socket, address): assert socket.recv(4) == b' V2' assert socket.recv(11) == b'MPUB topic\n' size = nsq.unpack_size(socket.recv(4)) data = socket.recv(size) head, data = data[:4], data[4:] assert nsq.unpack_size(head) == 2 for _ in range(2): head, data = data[:4], data[4:] assert nsq.unpack_size(head) == 3 head, data = data[:3], data[3:] assert head == b'sup' assert data == b''
def handle(socket, address): assert socket.recv(4) == b' V2' assert socket.recv(9) == b'IDENTIFY\n' size = nsq.unpack_size(socket.recv(4)) data = json.loads(socket.recv(size).decode('utf-8')) assert 'gnsq' in data['user_agent'] socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, b'OK'))
def handle(socket, address): assert socket.recv(4) == ' V2' assert socket.recv(5) == 'AUTH\n' assert nsq.unpack_size(socket.recv(4)) == 6 assert socket.recv(6) == 'secret' resp = json.dumps({'identity': 'awesome'}) socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, resp))
def handle(socket, address): assert socket.recv(4) == ' V2' assert socket.recv(11) == 'MPUB topic\n' size = nsq.unpack_size(socket.recv(4)) data = socket.recv(size) head, data = data[:4], data[4:] assert nsq.unpack_size(head) == 2 for _ in xrange(2): head, data = data[:4], data[4:] assert nsq.unpack_size(head) == 3 head, data = data[:3], data[3:] assert head == 'sup' assert data == ''
def handle(socket, address): assert socket.recv(4) == ' V2' assert socket.recv(9) == 'IDENTIFY\n' size = nsq.unpack_size(socket.recv(4)) data = json.loads(socket.recv(size)) assert 'gnsq' in data['user_agent'] socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, 'OK'))
def handle(socket, address): assert socket.recv(4) == ' V2' assert socket.recv(9) == 'IDENTIFY\n' size = nsq.unpack_size(socket.recv(4)) data = json.loads(socket.recv(size)) assert 'gnsq' in data['user_agent'] resp = json.dumps({'test': 42}) socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, resp))
def handle(socket, address): assert socket.recv(4) == b' V2' assert socket.recv(9) == b'IDENTIFY\n' size = nsq.unpack_size(socket.recv(4)) data = json.loads(socket.recv(size).decode('utf-8')) assert 'gnsq' in data['user_agent'] resp = six.b(json.dumps({'test': 42})) socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, resp))
def handle(socket, address): assert socket.recv(4) == b' V2' assert socket.recv(9) == b'IDENTIFY\n' size = nsq.unpack_size(socket.recv(4)) data = json.loads(socket.recv(size).decode('utf-8')) assert isinstance(data, dict) socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, b'OK')) msg = b'SUB topic channel\n' assert socket.recv(len(msg)) == msg socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, b'OK')) for i in range(10): assert socket.recv(6) == b'RDY 1\n' body = six.b(json.dumps({'data': {'test_key': i}})) ts = i * 1000 * 1000 socket.send(mock_response_message(ts, i, i, body))
def handle(socket, address): assert socket.recv(4) == ' V2' assert socket.recv(9) == 'IDENTIFY\n' size = nsq.unpack_size(socket.recv(4)) data = json.loads(socket.recv(size)) assert isinstance(data, dict) socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, 'OK')) msg = 'SUB topic channel\n' assert socket.recv(len(msg)) == msg socket.send(mock_response(nsq.FRAME_TYPE_RESPONSE, 'OK')) for i in xrange(10): assert socket.recv(6) == 'RDY 1\n' body = json.dumps({'data': {'test_key': i}}) ts = i * 1000 * 1000 socket.send(mock_response_message(ts, i, i, body))
def handle(socket, address): assert socket.recv(4) == b' V2' assert socket.recv(10) == b'PUB topic\n' assert nsq.unpack_size(socket.recv(4)) == 3 assert socket.recv(3) == b'sup'
def handle(socket, address): assert socket.recv(4) == ' V2' assert socket.recv(10) == 'PUB topic\n' assert nsq.unpack_size(socket.recv(4)) == 3 assert socket.recv(3) == 'sup'
def handle(socket, address): assert socket.recv(4) == b' V2' assert socket.recv(14) == b'DPUB topic 42\n' assert nsq.unpack_size(socket.recv(4)) == 3 assert socket.recv(3) == b'sup'