Pyright
This commit is contained in:
parent
ba184a2667
commit
fb7d0c8dac
1 changed files with 8 additions and 4 deletions
|
|
@ -188,7 +188,9 @@ async def test_ws_client_happy_request_and_response(
|
||||||
initialized_ws_client_session: ClientSession,
|
initialized_ws_client_session: ClientSession,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test a successful request and response via WebSocket"""
|
"""Test a successful request and response via WebSocket"""
|
||||||
result = await initialized_ws_client_session.read_resource("foobar://example")
|
result = await initialized_ws_client_session.read_resource(
|
||||||
|
AnyUrl("foobar://example")
|
||||||
|
)
|
||||||
assert isinstance(result, ReadResourceResult)
|
assert isinstance(result, ReadResourceResult)
|
||||||
assert isinstance(result.contents, list)
|
assert isinstance(result.contents, list)
|
||||||
assert len(result.contents) > 0
|
assert len(result.contents) > 0
|
||||||
|
|
@ -202,7 +204,7 @@ async def test_ws_client_exception_handling(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test exception handling in WebSocket communication"""
|
"""Test exception handling in WebSocket communication"""
|
||||||
with pytest.raises(McpError) as exc_info:
|
with pytest.raises(McpError) as exc_info:
|
||||||
await initialized_ws_client_session.read_resource("unknown://example")
|
await initialized_ws_client_session.read_resource(AnyUrl("unknown://example"))
|
||||||
assert exc_info.value.error.code == 404
|
assert exc_info.value.error.code == 404
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -214,11 +216,13 @@ async def test_ws_client_timeout(
|
||||||
# Set a very short timeout to trigger a timeout exception
|
# Set a very short timeout to trigger a timeout exception
|
||||||
with pytest.raises(TimeoutError):
|
with pytest.raises(TimeoutError):
|
||||||
with anyio.fail_after(0.1): # 100ms timeout
|
with anyio.fail_after(0.1): # 100ms timeout
|
||||||
await initialized_ws_client_session.read_resource("slow://example")
|
await initialized_ws_client_session.read_resource(AnyUrl("slow://example"))
|
||||||
|
|
||||||
# Now test that we can still use the session after a timeout
|
# Now test that we can still use the session after a timeout
|
||||||
with anyio.fail_after(5): # Longer timeout to allow completion
|
with anyio.fail_after(5): # Longer timeout to allow completion
|
||||||
result = await initialized_ws_client_session.read_resource("foobar://example")
|
result = await initialized_ws_client_session.read_resource(
|
||||||
|
AnyUrl("foobar://example")
|
||||||
|
)
|
||||||
assert isinstance(result, ReadResourceResult)
|
assert isinstance(result, ReadResourceResult)
|
||||||
assert isinstance(result.contents, list)
|
assert isinstance(result.contents, list)
|
||||||
assert len(result.contents) > 0
|
assert len(result.contents) > 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue