Client-side 2026-07-28 support: .discover()/.adopt() + Client(mode=); request-metadata green (#2950)
This commit is contained in:
parent
ae13ede143
commit
f226d00d0a
1 changed files with 2533 additions and 993 deletions
|
|
@ -9,13 +9,17 @@ pytestmark = pytest.mark.anyio
|
|||
|
||||
|
||||
async def test_progress_token_zero_first_call():
|
||||
"""Test that progress notifications work when progress_token is 0 on first call."""
|
||||
"""Regression: progress reporting must not be gated on a falsy token.
|
||||
|
||||
# Create mock session with progress notification tracking
|
||||
Issue #176: the original Context.report_progress treated token 0 as "no token" and
|
||||
silently dropped progress. Context now delegates unconditionally to
|
||||
ServerSession.report_progress (which calls DispatchContext.progress, whose JSONRPC
|
||||
implementation gates on `is None`, not truthiness), so a request whose meta carries
|
||||
a 0-valued token still emits all three reports.
|
||||
"""
|
||||
mock_session = AsyncMock()
|
||||
mock_session.send_progress_notification = AsyncMock()
|
||||
mock_session.report_progress = AsyncMock()
|
||||
|
||||
# Create request context with progress token 0
|
||||
request_context = ServerRequestContext(
|
||||
request_id="test-request",
|
||||
session=mock_session,
|
||||
|
|
@ -25,22 +29,14 @@ async def test_progress_token_zero_first_call():
|
|||
protocol_version="2025-11-25",
|
||||
)
|
||||
|
||||
# Create context with our mocks
|
||||
ctx = Context(request_context=request_context, mcp_server=MagicMock())
|
||||
|
||||
# Test progress reporting
|
||||
await ctx.report_progress(0, 10) # First call with 0
|
||||
await ctx.report_progress(5, 10) # Middle progress
|
||||
await ctx.report_progress(10, 10) # Complete
|
||||
await ctx.report_progress(0, 10)
|
||||
await ctx.report_progress(5, 10)
|
||||
await ctx.report_progress(10, 10)
|
||||
|
||||
# Verify progress notifications
|
||||
assert mock_session.send_progress_notification.call_count == 3, "All progress notifications should be sent"
|
||||
mock_session.send_progress_notification.assert_any_call(
|
||||
progress_token=0, progress=0.0, total=10.0, message=None, related_request_id="test-request"
|
||||
)
|
||||
mock_session.send_progress_notification.assert_any_call(
|
||||
progress_token=0, progress=5.0, total=10.0, message=None, related_request_id="test-request"
|
||||
)
|
||||
mock_session.send_progress_notification.assert_any_call(
|
||||
progress_token=0, progress=10.0, total=10.0, message=None, related_request_id="test-request"
|
||||
)
|
||||
assert mock_session.report_progress.await_args_list == [
|
||||
((0, 10, None),),
|
||||
((5, 10, None),),
|
||||
((10, 10, None),),
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue