def make_fut(cmd, *args, **kw): fut = create_future(asyncio.get_event_loop()) if cmd == 'PING': fut.set_result(b'QUEUED') elif cmd == 'EXEC': fut.set_result([b'PONG']) else: fut.set_result(b'OK') return fut
def make_fut(cmd, *args, **kw): fut = create_future(asyncio.get_event_loop()) if cmd == 'PING': fut.set_result(b'QUEUED') elif cmd == 'EXEC': fut.set_result([b'PONG']) else: fut.set_result(b'OK') return fut
def test_publish(create_connection, redis, server, loop): out = asyncio.Queue(loop=loop) fut = create_future(loop=loop) conn = yield from create_connection(server.tcp_address, loop=loop) sub = async_task(_reader('chan:1', out, fut, conn), loop=loop) yield from fut yield from redis.publish('chan:1', 'Hello') msg = yield from out.get() assert msg == b'Hello' sub.cancel()
def test_publish(create_connection, redis, server, loop): out = asyncio.Queue(loop=loop) fut = create_future(loop=loop) conn = yield from create_connection( server.tcp_address, loop=loop) sub = asyncio.async(_reader('chan:1', out, fut, conn), loop=loop) yield from fut yield from redis.publish('chan:1', 'Hello') msg = yield from out.get() assert msg == b'Hello' sub.cancel()
def test_publish_json(create_connection, redis, server, loop): out = asyncio.Queue(loop=loop) fut = create_future(loop=loop) conn = yield from create_connection(server.tcp_address, loop=loop) sub = async_task(_reader('chan:1', out, fut, conn), loop=loop) yield from fut res = yield from redis.publish_json('chan:1', {"Hello": "world"}) assert res == 1 # recievers msg = yield from out.get() assert msg == b'{"Hello": "world"}' sub.cancel()
def test_publish_json(create_connection, redis, server, loop): out = asyncio.Queue(loop=loop) fut = create_future(loop=loop) conn = yield from create_connection( server.tcp_address, loop=loop) sub = asyncio.async(_reader('chan:1', out, fut, conn), loop=loop) yield from fut res = yield from redis.publish_json('chan:1', {"Hello": "world"}) assert res == 1 # recievers msg = yield from out.get() assert msg == b'{"Hello": "world"}' sub.cancel()