Coverage for docs/docs_src/getting_started/dependencies/basic/redis/overrides.py: 93%
15 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-17 21:20 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-17 21:20 +0000
1import pytest
2from faststream import FastStream, Depends
3from faststream.redis import RedisBroker, TestRedisBroker
5broker = RedisBroker("redis://localhost:6379")
6app = FastStream(broker)
8def get_client() -> str:
9 return "real client"
11@broker.subscriber("test")
12async def handler(body: dict, client: str = Depends(get_client)) -> str:
13 return client
15def get_fake_client() -> str:
16 return "fake client"
18@pytest.mark.asyncio
19async def test_handler() -> None:
20 with broker.provider.scope(get_client, get_fake_client):
21 async with TestRedisBroker(broker) as br:
22 response = await br.request({}, "test")
23 assert await response.decode() == "fake client"