/ fastapi-template-users / tests / test_redis.py
test_redis.py
 1  from _pytest.monkeypatch import MonkeyPatch
 2  from aioredis import Redis
 3  
 4  from ._utils import import_module
 5  from api import redis
 6  from api.settings import settings
 7  
 8  
 9  async def test__redis(monkeypatch: MonkeyPatch) -> None:
10      monkeypatch.setattr(settings, "redis_url", "redis://my_redis_host:4953/42")
11  
12      r = import_module(redis).redis
13  
14      assert isinstance(r, Redis)
15      assert r.connection_pool.connection_kwargs == {
16          "host": "my_redis_host",
17          "port": 4953,
18          "db": 42,
19          "encoding": "utf-8",
20          "decode_responses": True,
21      }