55
66from tests .utils import fixture_text
77from workflowai .core .client ._models import RunResponse
8- from workflowai .core .client ._utils import intolerant_validator , tolerant_validator
8+ from workflowai .core .client ._utils import default_validator
99from workflowai .core .domain .run import Run
1010from workflowai .core .domain .tool_call import ToolCallRequest
1111
@@ -41,29 +41,30 @@ def test_no_version_not_optional(self):
4141 with pytest .raises (ValidationError ): # sanity
4242 _TaskOutput .model_validate ({"a" : 1 })
4343
44- parsed = chunk .to_domain (task_id = "1" , task_schema_id = 1 , validator = tolerant_validator (_TaskOutput ))
44+ parsed = chunk .to_domain (task_id = "1" , task_schema_id = 1 , validator = default_validator (_TaskOutput ))
4545 assert isinstance (parsed , Run )
4646 assert parsed .output .a == 1
4747 # b is not defined
48- with pytest . raises ( AttributeError ):
49- assert parsed .output .b
48+
49+ assert parsed .output .b == ""
5050
5151 def test_no_version_optional (self ):
5252 chunk = RunResponse .model_validate_json ('{"id": "1", "task_output": {"a": 1}}' )
5353 assert chunk
5454
55- parsed = chunk .to_domain (task_id = "1" , task_schema_id = 1 , validator = tolerant_validator (_TaskOutputOpt ))
55+ parsed = chunk .to_domain (task_id = "1" , task_schema_id = 1 , validator = default_validator (_TaskOutputOpt ))
5656 assert isinstance (parsed , Run )
5757 assert parsed .output .a == 1
5858 assert parsed .output .b is None
5959
6060 def test_with_version (self ):
61+ """Full output is validated since the duration is passed and there are no tool calls"""
6162 chunk = RunResponse .model_validate_json (
6263 '{"id": "1", "task_output": {"a": 1, "b": "test"}, "cost_usd": 0.1, "duration_seconds": 1, "version": {"properties": {"a": 1, "b": "test"}}}' , # noqa: E501
6364 )
6465 assert chunk
6566
66- parsed = chunk .to_domain (task_id = "1" , task_schema_id = 1 , validator = tolerant_validator (_TaskOutput ))
67+ parsed = chunk .to_domain (task_id = "1" , task_schema_id = 1 , validator = default_validator (_TaskOutput ))
6768 assert isinstance (parsed , Run )
6869 assert parsed .output .a == 1
6970 assert parsed .output .b == "test"
@@ -73,17 +74,19 @@ def test_with_version(self):
7374
7475 def test_with_version_validation_fails (self ):
7576 chunk = RunResponse .model_validate_json (
76- '{"id": "1", "task_output": {"a": 1}, "version": {"properties": {"a": 1, "b": "test"}}}' ,
77+ """{"id": "1", "task_output": {"a": 1},
78+ "version": {"properties": {"a": 1, "b": "test"}}, "duration_seconds": 1}""" ,
7779 )
7880 with pytest .raises (ValidationError ):
79- chunk .to_domain (task_id = "1" , task_schema_id = 1 , validator = intolerant_validator (_TaskOutput ))
81+ chunk .to_domain (task_id = "1" , task_schema_id = 1 , validator = default_validator (_TaskOutput ))
8082
8183 def test_with_tool_calls (self ):
8284 chunk = RunResponse .model_validate_json (
83- '{"id": "1", "task_output": {}, "tool_call_requests": [{"id": "1", "name": "test", "input": {"a": 1}}]}' ,
85+ """{"id": "1", "task_output": {},
86+ "tool_call_requests": [{"id": "1", "name": "test", "input": {"a": 1}}], "duration_seconds": 1}""" ,
8487 )
8588 assert chunk
8689
87- parsed = chunk .to_domain (task_id = "1" , task_schema_id = 1 , validator = tolerant_validator (_TaskOutput ))
90+ parsed = chunk .to_domain (task_id = "1" , task_schema_id = 1 , validator = default_validator (_TaskOutput ))
8891 assert isinstance (parsed , Run )
8992 assert parsed .tool_call_requests == [ToolCallRequest (id = "1" , name = "test" , input = {"a" : 1 })]
0 commit comments