Skip to content

Commit 554f63d

Browse files
committed
Test ValidationError
1 parent 5ff4155 commit 554f63d

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/contrib/pydantic/test_pydantic.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import uuid
33
from datetime import datetime
44

5+
import pydantic
56
import pytest
67
from pydantic import BaseModel
78

@@ -25,6 +26,7 @@
2526
PydanticModelWithStrictFieldWorkflow,
2627
RoundTripMiscObjectsWorkflow,
2728
RoundTripPydanticObjectsWorkflow,
29+
ValidationErrorWorkflow,
2830
_test_pydantic_model_with_strict_field,
2931
clone_objects,
3032
misc_objects_activity,
@@ -302,3 +304,24 @@ async def test_no_type_annotations(client: Client):
302304
task_queue=task_queue_name,
303305
)
304306
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+
)

tests/contrib/pydantic/workflows.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,10 @@ class NoTypeAnnotationsWorkflow:
173173
@workflow.run
174174
async def run(self, arg):
175175
return arg
176+
177+
178+
@workflow.defn
179+
class ValidationErrorWorkflow:
180+
@workflow.run
181+
async def run(self, arg):
182+
return arg

0 commit comments

Comments
 (0)