def test_make_store(): conn = pylibmc.Client(['127.0.0.1'], binary=True, behaviors={'tcp_nodelay': True, 'ketama': True}) store = shorten.make_store('memcache', memcache_client=conn, counter_key=COUNTER_KEY) assert store assert isinstance(store, shorten.MemcacheStore)
def init_app(app): redis_client = redis.Redis(host=shortconf.SHORTNER_HOST, port=shortconf.SHORTNER_PORT, db=shortconf.SHORTNER_DB) formatter = NamespacedFormatter(shortconf.FORMATTER) token_gen = UUIDTokenGenerator() store_params = { shortconf.SHORTNER_CLIENT: redis_client, "counter_key": shortconf.COUNTER_KEY, "formatter": formatter, "token_gen": token_gen, "alphabet": alphabets.URLSAFE_DISSIMILAR } stored = make_store(name=shortconf.SHORTNER_STORE, min_length=shortconf.MIN_LENGTH, **store_params) return stored
def test_make_store(): conn = redis.Redis() store = shorten.make_store('redis', redis_client=conn, counter_key=COUNTER_KEY) assert store assert isinstance(store, shorten.RedisStore)