Skip to content

Commit 9ccf80e

Browse files
test: add regression test for content type literal defaults
Github-Issue: #1731
1 parent 2af18bc commit 9ccf80e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/test_types.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
CreateMessageRequestParams,
1010
CreateMessageResult,
1111
CreateMessageResultWithTools,
12+
ImageContent,
1213
Implementation,
1314
InitializeRequest,
1415
InitializeRequestParams,
1516
JSONRPCMessage,
1617
JSONRPCRequest,
1718
ListToolsResult,
19+
PromptReference,
1820
SamplingCapability,
1921
SamplingMessage,
2022
TextContent,
@@ -71,6 +73,17 @@ async def test_method_initialization():
7173
assert initialize_request.params.protocolVersion == LATEST_PROTOCOL_VERSION
7274

7375

76+
def test_content_type_literal_defaults():
77+
"""Content types should default their Literal type field.
78+
79+
This allows instantiation without explicitly passing the type discriminator,
80+
e.g., TextContent(text="hello") instead of TextContent(type="text", text="hello").
81+
"""
82+
assert TextContent(text="hello").type == "text"
83+
assert ImageContent(data="base64", mimeType="image/png").type == "image"
84+
assert PromptReference(name="test").type == "ref/prompt"
85+
86+
7487
@pytest.mark.anyio
7588
async def test_tool_use_content():
7689
"""Test ToolUseContent type for SEP-1577."""

0 commit comments

Comments
 (0)