|
2 | 2 | import uuid |
3 | 3 | from datetime import datetime |
4 | 4 |
|
| 5 | +import pydantic |
5 | 6 | import pytest |
6 | 7 | from pydantic import BaseModel |
7 | 8 |
|
|
25 | 26 | PydanticModelWithStrictFieldWorkflow, |
26 | 27 | RoundTripMiscObjectsWorkflow, |
27 | 28 | RoundTripPydanticObjectsWorkflow, |
| 29 | + ValidationErrorWorkflow, |
28 | 30 | _test_pydantic_model_with_strict_field, |
29 | 31 | clone_objects, |
30 | 32 | misc_objects_activity, |
@@ -302,3 +304,24 @@ async def test_no_type_annotations(client: Client): |
302 | 304 | task_queue=task_queue_name, |
303 | 305 | ) |
304 | 306 | assert result == [7] |
| 307 | + |
| 308 | + |
| 309 | +async def test_validation_error(client: Client): |
| 310 | + new_config = client.config() |
| 311 | + new_config["data_converter"] = pydantic_data_converter |
| 312 | + client = Client(**new_config) |
| 313 | + task_queue_name = str(uuid.uuid4()) |
| 314 | + |
| 315 | + async with Worker( |
| 316 | + client, |
| 317 | + task_queue=task_queue_name, |
| 318 | + workflows=[ValidationErrorWorkflow], |
| 319 | + ): |
| 320 | + with pytest.raises(pydantic.ValidationError): |
| 321 | + await client.execute_workflow( |
| 322 | + "ValidationErrorWorkflow", |
| 323 | + "not-an-int", |
| 324 | + id=str(uuid.uuid4()), |
| 325 | + task_queue=task_queue_name, |
| 326 | + result_type=tuple[int], |
| 327 | + ) |
0 commit comments