refactor: use snake case instead of camel case in types (#1894)
This commit is contained in:
parent
7080fcf1e6
commit
e94b386a13
1 changed files with 1063 additions and 1057 deletions
|
|
@ -106,7 +106,7 @@ async def test_content_only_without_output_schema():
|
|||
Tool(
|
||||
name="echo",
|
||||
description="Echo a message",
|
||||
inputSchema={
|
||||
input_schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message": {"type": "string"},
|
||||
|
|
@ -130,12 +130,12 @@ async def test_content_only_without_output_schema():
|
|||
|
||||
# Verify results
|
||||
assert result is not None
|
||||
assert not result.isError
|
||||
assert not result.is_error
|
||||
assert len(result.content) == 1
|
||||
assert result.content[0].type == "text"
|
||||
assert isinstance(result.content[0], TextContent)
|
||||
assert result.content[0].text == "Echo: Hello"
|
||||
assert result.structuredContent is None
|
||||
assert result.structured_content is None
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
|
@ -145,7 +145,7 @@ async def test_dict_only_without_output_schema():
|
|||
Tool(
|
||||
name="get_info",
|
||||
description="Get structured information",
|
||||
inputSchema={
|
||||
input_schema={
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
},
|
||||
|
|
@ -166,13 +166,13 @@ async def test_dict_only_without_output_schema():
|
|||
|
||||
# Verify results
|
||||
assert result is not None
|
||||
assert not result.isError
|
||||
assert not result.is_error
|
||||
assert len(result.content) == 1
|
||||
assert result.content[0].type == "text"
|
||||
assert isinstance(result.content[0], TextContent)
|
||||
# Check that the content is the JSON serialization
|
||||
assert json.loads(result.content[0].text) == {"status": "ok", "data": {"value": 42}}
|
||||
assert result.structuredContent == {"status": "ok", "data": {"value": 42}}
|
||||
assert result.structured_content == {"status": "ok", "data": {"value": 42}}
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
|
@ -182,7 +182,7 @@ async def test_both_content_and_dict_without_output_schema():
|
|||
Tool(
|
||||
name="process",
|
||||
description="Process data",
|
||||
inputSchema={
|
||||
input_schema={
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
},
|
||||
|
|
@ -205,12 +205,12 @@ async def test_both_content_and_dict_without_output_schema():
|
|||
|
||||
# Verify results
|
||||
assert result is not None
|
||||
assert not result.isError
|
||||
assert not result.is_error
|
||||
assert len(result.content) == 1
|
||||
assert result.content[0].type == "text"
|
||||
assert isinstance(result.content[0], TextContent)
|
||||
assert result.content[0].text == "Processing complete"
|
||||
assert result.structuredContent == {"result": "success", "count": 10}
|
||||
assert result.structured_content == {"result": "success", "count": 10}
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
|
@ -220,11 +220,11 @@ async def test_content_only_with_output_schema_error():
|
|||
Tool(
|
||||
name="structured_tool",
|
||||
description="Tool expecting structured output",
|
||||
inputSchema={
|
||||
input_schema={
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
},
|
||||
outputSchema={
|
||||
output_schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"result": {"type": "string"},
|
||||
|
|
@ -245,7 +245,7 @@ async def test_content_only_with_output_schema_error():
|
|||
|
||||
# Verify error
|
||||
assert result is not None
|
||||
assert result.isError
|
||||
assert result.is_error
|
||||
assert len(result.content) == 1
|
||||
assert result.content[0].type == "text"
|
||||
assert isinstance(result.content[0], TextContent)
|
||||
|
|
@ -259,7 +259,7 @@ async def test_valid_dict_with_output_schema():
|
|||
Tool(
|
||||
name="calc",
|
||||
description="Calculate result",
|
||||
inputSchema={
|
||||
input_schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"x": {"type": "number"},
|
||||
|
|
@ -267,7 +267,7 @@ async def test_valid_dict_with_output_schema():
|
|||
},
|
||||
"required": ["x", "y"],
|
||||
},
|
||||
outputSchema={
|
||||
output_schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"sum": {"type": "number"},
|
||||
|
|
@ -293,12 +293,12 @@ async def test_valid_dict_with_output_schema():
|
|||
|
||||
# Verify results
|
||||
assert result is not None
|
||||
assert not result.isError
|
||||
assert not result.is_error
|
||||
assert len(result.content) == 1
|
||||
assert result.content[0].type == "text"
|
||||
# Check JSON serialization
|
||||
assert json.loads(result.content[0].text) == {"sum": 7, "product": 12}
|
||||
assert result.structuredContent == {"sum": 7, "product": 12}
|
||||
assert result.structured_content == {"sum": 7, "product": 12}
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
|
@ -308,11 +308,11 @@ async def test_invalid_dict_with_output_schema():
|
|||
Tool(
|
||||
name="user_info",
|
||||
description="Get user information",
|
||||
inputSchema={
|
||||
input_schema={
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
},
|
||||
outputSchema={
|
||||
output_schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
|
|
@ -337,7 +337,7 @@ async def test_invalid_dict_with_output_schema():
|
|||
|
||||
# Verify error
|
||||
assert result is not None
|
||||
assert result.isError
|
||||
assert result.is_error
|
||||
assert len(result.content) == 1
|
||||
assert result.content[0].type == "text"
|
||||
assert isinstance(result.content[0], TextContent)
|
||||
|
|
@ -352,14 +352,14 @@ async def test_both_content_and_valid_dict_with_output_schema():
|
|||
Tool(
|
||||
name="analyze",
|
||||
description="Analyze data",
|
||||
inputSchema={
|
||||
input_schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"text": {"type": "string"},
|
||||
},
|
||||
"required": ["text"],
|
||||
},
|
||||
outputSchema={
|
||||
output_schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"sentiment": {"type": "string", "enum": ["positive", "negative", "neutral"]},
|
||||
|
|
@ -385,11 +385,11 @@ async def test_both_content_and_valid_dict_with_output_schema():
|
|||
|
||||
# Verify results
|
||||
assert result is not None
|
||||
assert not result.isError
|
||||
assert not result.is_error
|
||||
assert len(result.content) == 1
|
||||
assert result.content[0].type == "text"
|
||||
assert result.content[0].text == "Analysis of: Great job!"
|
||||
assert result.structuredContent == {"sentiment": "positive", "confidence": 0.95}
|
||||
assert result.structured_content == {"sentiment": "positive", "confidence": 0.95}
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
|
@ -399,7 +399,7 @@ async def test_tool_call_result():
|
|||
Tool(
|
||||
name="get_info",
|
||||
description="Get structured information",
|
||||
inputSchema={
|
||||
input_schema={
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
},
|
||||
|
|
@ -411,7 +411,7 @@ async def test_tool_call_result():
|
|||
if name == "get_info":
|
||||
return CallToolResult(
|
||||
content=[TextContent(type="text", text="Results calculated")],
|
||||
structuredContent={"status": "ok", "data": {"value": 42}},
|
||||
structured_content={"status": "ok", "data": {"value": 42}},
|
||||
_meta={"some": "metadata"},
|
||||
)
|
||||
else: # pragma: no cover
|
||||
|
|
@ -424,12 +424,12 @@ async def test_tool_call_result():
|
|||
|
||||
# Verify results
|
||||
assert result is not None
|
||||
assert not result.isError
|
||||
assert not result.is_error
|
||||
assert len(result.content) == 1
|
||||
assert result.content[0].type == "text"
|
||||
assert result.content[0].text == "Results calculated"
|
||||
assert isinstance(result.content[0], TextContent)
|
||||
assert result.structuredContent == {"status": "ok", "data": {"value": 42}}
|
||||
assert result.structured_content == {"status": "ok", "data": {"value": 42}}
|
||||
assert result.meta == {"some": "metadata"}
|
||||
|
||||
|
||||
|
|
@ -440,11 +440,11 @@ async def test_output_schema_type_validation():
|
|||
Tool(
|
||||
name="stats",
|
||||
description="Get statistics",
|
||||
inputSchema={
|
||||
input_schema={
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
},
|
||||
outputSchema={
|
||||
output_schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"count": {"type": "integer"},
|
||||
|
|
@ -470,7 +470,7 @@ async def test_output_schema_type_validation():
|
|||
|
||||
# Verify error
|
||||
assert result is not None
|
||||
assert result.isError
|
||||
assert result.is_error
|
||||
assert len(result.content) == 1
|
||||
assert result.content[0].type == "text"
|
||||
assert "Output validation error:" in result.content[0].text
|
||||
|
|
|
|||
Loading…
Reference in a new issue