Esempio n. 1
0
 def setup(self, io_loop):
     register_redis_options("master", "redis://localhost/0")
     register_redis_options("slave", "redis://localhost/0")
Esempio n. 2
0
#        H A P P Y    H A C K I N G !
#              _____               ______
#     ____====  ]OO|_n_n__][.      |    |
#    [________]_|__|________)<     |YANG|
#     oo    oo  'oo OOOO-| oo\\_   ~o~~o~
# +--+--+--+--+--+--+--+--+--+--+--+--+--+
#               Jianing Yang @ 28 Apr, 2018
#
from asyncio import wait as async_wait
from tornado_battery.redis import register_redis_options, with_redis
from tornado_battery.redis import RedisConnector
from tornado_battery.locks import throttle, ThrottleExceeded
import pytest

pytestmark = pytest.mark.asyncio
register_redis_options('locks', 'redis://127.0.0.1/0')


@pytest.fixture
async def redis():
    redis = RedisConnector.instance('locks')
    await redis.connect()
    yield redis


@with_redis(name='locks')
async def clear(key, redis):
    await redis.execute('DEL', f'throttle_{key}')


@with_redis(name='locks')
Esempio n. 3
0
# -*- coding: utf-8 -*-
#
#        H A P P Y    H A C K I N G !
#              _____               ______
#     ____====  ]OO|_n_n__][.      |    |
#    [________]_|__|________)<     |YANG|
#     oo    oo  'oo OOOO-| oo\\_   ~o~~o~
# +--+--+--+--+--+--+--+--+--+--+--+--+--+
#               Jianing Yang @ 16 Feb, 2018
#
from tornado_battery.redis import register_redis_options, with_redis
from tornado_battery.redis import RedisConnector, RedisConnectorError
import pytest

pytestmark = pytest.mark.asyncio
register_redis_options('test', 'redis://127.0.0.1/0')


@pytest.fixture
async def redis():
    from tornado_battery.redis import connect_redis
    redis = RedisConnector.instance('test')
    connect = connect_redis('test')
    await connect()
    return redis


@pytest.mark.asyncio
async def test_set_command(redis):
    db = await redis.acquire()
    value = await db.execute('set', 'redis_value', '1984')
Esempio n. 4
0
# -*- coding: utf-8 -*-
#
#        H A P P Y    H A C K I N G !
#              _____               ______
#     ____====  ]OO|_n_n__][.      |    |
#    [________]_|__|________)<     |YANG|
#     oo    oo  'oo OOOO-| oo\\_   ~o~~o~
# +--+--+--+--+--+--+--+--+--+--+--+--+--+
#               Jianing Yang @ 16 Feb, 2018
#
from tornado_battery.redis import register_redis_options, with_redis
from tornado_battery.redis import RedisConnector, RedisConnectorError
import pytest

pytestmark = pytest.mark.asyncio
register_redis_options("test", "redis://127.0.0.1/0")


@pytest.fixture
async def redis():
    redis = RedisConnector.instance("test")
    await redis.connect()
    return redis


async def test_set_command(redis):
    async with redis.connection() as db:
        value = await db.execute("set", "redis_value", "1984")
    assert value == "OK"