|
10 | 10 | from mcp.shared.message import SessionMessage |
11 | 11 |
|
12 | 12 |
|
13 | | -@pytest.mark.anyio |
14 | | -async def test_session_exists(message_dispatch): |
15 | | - """Test session existence check.""" |
16 | | - session_id = uuid4() |
17 | | - |
18 | | - # Initially session should not exist |
19 | | - assert not await message_dispatch.session_exists(session_id) |
20 | | - |
21 | | - # After subscribing, session should exist |
22 | | - async with message_dispatch.subscribe(session_id, AsyncMock()): |
23 | | - assert await message_dispatch.session_exists(session_id) |
24 | | - |
25 | | - # After unsubscribing, session should not exist |
26 | | - assert not await message_dispatch.session_exists(session_id) |
27 | | - |
28 | | - |
29 | | -@pytest.mark.anyio |
30 | | -async def test_session_ttl(message_dispatch): |
31 | | - """Test that session has proper TTL set.""" |
32 | | - session_id = uuid4() |
33 | | - |
34 | | - async with message_dispatch.subscribe(session_id, AsyncMock()): |
35 | | - session_key = message_dispatch._session_key(session_id) |
36 | | - ttl = await message_dispatch._redis.ttl(session_key) # type: ignore |
37 | | - assert ttl > 0 |
38 | | - assert ttl <= message_dispatch._session_ttl |
39 | | - |
40 | 13 |
|
41 | 14 | @pytest.mark.anyio |
42 | 15 | async def test_session_heartbeat(message_dispatch): |
@@ -129,12 +102,12 @@ async def test_publish_message_invalid_json(message_dispatch): |
129 | 102 |
|
130 | 103 |
|
131 | 104 | @pytest.mark.anyio |
132 | | -async def test_publish_to_nonexistent_session(message_dispatch): |
| 105 | +async def test_publish_to_nonexistent_session(message_dispatch: RedisMessageDispatch): |
133 | 106 | """Test publishing to a session that doesn't exist.""" |
134 | 107 | session_id = uuid4() |
135 | | - message = types.JSONRPCMessage.model_validate( |
| 108 | + message = SessionMessage(message=types.JSONRPCMessage.model_validate( |
136 | 109 | {"jsonrpc": "2.0", "method": "test", "params": {}, "id": 1} |
137 | | - ) |
| 110 | + )) |
138 | 111 |
|
139 | 112 | published = await message_dispatch.publish_message(session_id, message) |
140 | 113 | assert not published |
|
0 commit comments