Esempio n. 1
0
 async def test_connect_stores_pool(self):
     with patch("aiocache.backends.redis.aioredis.create_pool") as create_pool:
         pool = FakePool()
         create_pool.return_value = pool
         redis = RedisBackend()
         await redis._connect()
     assert RedisBackend.pools[redis.get_pool()[0]] is pool
Esempio n. 2
0
 async def test_connect_with_pool(self):
     redis = RedisBackend()
     pool = FakePool()
     redis.get_pool = MagicMock(return_value=["key", pool])
     assert await redis._connect() == pool
Esempio n. 3
0
 def test_get_pool(self):
     redis = RedisBackend()
     pool_key, pool = redis.get_pool()
     assert pool_key == "{}{}{}{}{}{}".format(
         redis.endpoint, redis.port, getattr(redis, "encoding", None),
         redis.db, redis.password, id(redis._loop))