diff --git a/tests/ext/workflow/test_mcp_schema.py b/tests/ext/workflow/test_mcp_schema.py index 6f369b712..6bf7871e4 100644 --- a/tests/ext/workflow/test_mcp_schema.py +++ b/tests/ext/workflow/test_mcp_schema.py @@ -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.""" @@ -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',