types: Setting default value for method: Literal (#1292)
This commit is contained in:
parent
9c6fd15a88
commit
07ae8c0d4e
1 changed files with 67 additions and 104 deletions
|
|
@ -1,6 +1,15 @@
|
|||
import pytest
|
||||
|
||||
from mcp.types import LATEST_PROTOCOL_VERSION, ClientRequest, JSONRPCMessage, JSONRPCRequest
|
||||
from mcp.types import (
|
||||
LATEST_PROTOCOL_VERSION,
|
||||
ClientCapabilities,
|
||||
ClientRequest,
|
||||
Implementation,
|
||||
InitializeRequest,
|
||||
InitializeRequestParams,
|
||||
JSONRPCMessage,
|
||||
JSONRPCRequest,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
|
@ -25,3 +34,25 @@ async def test_jsonrpc_request():
|
|||
assert request.root.method == "initialize"
|
||||
assert request.root.params is not None
|
||||
assert request.root.params["protocolVersion"] == LATEST_PROTOCOL_VERSION
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_method_initialization():
|
||||
"""
|
||||
Test that the method is automatically set on object creation.
|
||||
Testing just for InitializeRequest to keep the test simple, but should be set for other types as well.
|
||||
"""
|
||||
initialize_request = InitializeRequest(
|
||||
params=InitializeRequestParams(
|
||||
protocolVersion=LATEST_PROTOCOL_VERSION,
|
||||
capabilities=ClientCapabilities(),
|
||||
clientInfo=Implementation(
|
||||
name="mcp",
|
||||
version="0.1.0",
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
assert initialize_request.method == "initialize", "method should be set to 'initialize'"
|
||||
assert initialize_request.params is not None
|
||||
assert initialize_request.params.protocolVersion == LATEST_PROTOCOL_VERSION
|
||||
|
|
|
|||
Loading…
Reference in a new issue