Skip to content

Commit 21ce52a

Browse files
Add test for StreamableHTTPReconnectionOptions validation
1 parent acf90a0 commit 21ce52a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/shared/test_streamable_http.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,25 @@ async def test_streamablehttp_client_with_reconnection_options(basic_server: Non
18971897
assert isinstance(result, InitializeResult)
18981898

18991899

1900+
def test_reconnection_options_validation():
1901+
"""Test StreamableHTTPReconnectionOptions validates delay settings."""
1902+
from mcp.client.streamable_http import StreamableHTTPReconnectionOptions
1903+
1904+
# Valid options should work
1905+
valid = StreamableHTTPReconnectionOptions(
1906+
initial_reconnection_delay=1.0,
1907+
max_reconnection_delay=30.0,
1908+
)
1909+
assert valid.initial_reconnection_delay == 1.0
1910+
1911+
# Invalid options should raise
1912+
with pytest.raises(ValueError, match="initial_reconnection_delay cannot exceed"):
1913+
StreamableHTTPReconnectionOptions(
1914+
initial_reconnection_delay=60.0,
1915+
max_reconnection_delay=30.0,
1916+
)
1917+
1918+
19001919
@pytest.mark.anyio
19011920
async def test_streamablehttp_client_auto_reconnection(event_server: tuple[SimpleEventStore, str]):
19021921
"""Test automatic client reconnection when server closes SSE stream mid-operation."""

0 commit comments

Comments
 (0)