File tree Expand file tree Collapse file tree 3 files changed +163
-189
lines changed
tests/server/message_queue Expand file tree Collapse file tree 3 files changed +163
-189
lines changed Original file line number Diff line number Diff line change 1+ """Shared fixtures for message queue tests."""
2+
3+ from collections .abc import AsyncGenerator
4+ from unittest .mock import patch
5+
6+ import pytest
7+
8+ from mcp .server .message_queue .redis import RedisMessageDispatch
9+
10+ # Set up fakeredis for testing
11+ try :
12+ from fakeredis import aioredis as fake_redis
13+ except ImportError :
14+ pytest .skip (
15+ "fakeredis is required for testing Redis functionality" , allow_module_level = True
16+ )
17+
18+
19+ @pytest .fixture
20+ async def message_dispatch () -> AsyncGenerator [RedisMessageDispatch , None ]:
21+ """Create a shared Redis message dispatch with a fake Redis client."""
22+ with patch ("mcp.server.message_queue.redis.redis" , fake_redis .FakeRedis ):
23+ # Shorter TTL for testing
24+ message_dispatch = RedisMessageDispatch (session_ttl = 5 )
25+ try :
26+ yield message_dispatch
27+ finally :
28+ await message_dispatch .close ()
You can’t perform that action at this time.
0 commit comments