Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/ext/workflow/test_mcp_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,25 @@ def test_oneof_nullable_integer(self):
instance = Model(count=5)
self.assertEqual(instance.count, 5)

def test_anyof_array_variant(self):
schema = {
'type': 'object',
'properties': {
'tags': {
'anyOf': [
{'type': 'array', 'items': {'type': 'integer'}},
{'type': 'null'},
]
}
},
'required': ['tags'],
}
Model = create_pydantic_model_from_schema(schema, 'ArrayVariantModel')
instance = Model(tags=[1, 2, 3])
self.assertEqual(instance.tags, [1, 2, 3])
instance2 = Model(tags=None)
self.assertIsNone(instance2.tags)


class TestKwargsUnwrapping(unittest.TestCase):
"""Tests for the kwargs wrapper unwrapping pattern."""
Expand Down Expand Up @@ -228,6 +247,12 @@ def test_returns_pydantic_model_subclass(self):
Model = create_pydantic_model_from_schema(schema, 'SubclassCheck')
self.assertTrue(issubclass(Model, BaseModel))

def test_invalid_schema_raises_value_error(self):
schema = {'type': 'object', 'properties': {'x': 'not-a-dict'}}
with self.assertRaises(ValueError) as ctx:
create_pydantic_model_from_schema(schema, 'InvalidModel')
self.assertIn('Invalid schema', str(ctx.exception))

def test_model_name_set(self):
schema = {
'type': 'object',
Expand Down