Skip to content

Commit 5a1982d

Browse files
committed
chore: Add test for pydantic_model property
1 parent 89ccd9b commit 5a1982d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

packages/toolbox-core/tests/test_tool.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import pytest_asyncio
2424
from aiohttp import ClientSession
2525
from aioresponses import aioresponses
26-
from pydantic import ValidationError
26+
from pydantic import BaseModel, ValidationError
2727

2828
from toolbox_core.protocol import ParameterSchema
2929
from toolbox_core.tool import ToolboxTool, create_func_docstring, resolve_value
@@ -578,6 +578,24 @@ def test_toolbox_tool_underscore_client_headers_property(toolbox_tool: ToolboxTo
578578
client_headers["new_header"] = "new_value"
579579

580580

581+
def test_toolbox_tool_underscore_pydantic_model_property(toolbox_tool: ToolboxTool):
582+
"""Tests the _pydantic_model property returns the correct Pydantic model."""
583+
pydantic_model = toolbox_tool._pydantic_model
584+
assert issubclass(pydantic_model, BaseModel)
585+
assert pydantic_model.__name__ == TEST_TOOL_NAME
586+
587+
# Test that the model can validate expected data
588+
valid_data = {"message": "test", "count": 10}
589+
validated_data = pydantic_model.model_validate(valid_data)
590+
assert validated_data.message == "test"
591+
assert validated_data.count == 10
592+
593+
# Test that the model raises ValidationError for invalid data
594+
invalid_data = {"message": 123, "count": "not_an_int"}
595+
with pytest.raises(ValidationError):
596+
pydantic_model.model_validate(invalid_data)
597+
598+
581599
# --- Test for the HTTP Warning ---
582600
@pytest.mark.parametrize(
583601
"trigger_condition_params",

0 commit comments

Comments
 (0)