@@ -86,18 +86,44 @@ def test_implicit_collection_jobs_serialize_orphan_associations():
8686 assert rval ["jobs" ] == [42 ]
8787
8888
89- def test_get_identifier_for_id_null_handling ():
90- """Null job-param ids raise in strict mode and pass through in
91- tolerate_missing_data mode."""
89+ def test_job_serialize_with_null_param_ids ():
90+ """Driving Job._serialize end-to-end with a JobParameter that contains
91+ {"src": "hda", "id": null}: strict mode raises, tolerate_missing_data
92+ mode produces a serialized dict whose params preserve the null ref."""
93+ import datetime
94+ import json
95+
96+ job = model .Job ()
97+ job .id = 42
98+ job .tool_id = "cat1"
99+ job .tool_version = "1.0"
100+ job .galaxy_version = "test"
101+ job .state = "ok"
102+ job .info = None
103+ job .traceback = None
104+ job .command_line = None
105+ job .tool_stderr = None
106+ job .job_stderr = None
107+ job .tool_stdout = None
108+ job .job_stdout = None
109+ job .exit_code = 0
110+ job .create_time = datetime .datetime (2026 , 1 , 1 )
111+ job .update_time = datetime .datetime (2026 , 1 , 1 )
112+ job .job_messages = None
113+ job .object_store_id = None
114+ job .object_store_id_overrides = None
115+ job .parameters = [model .JobParameter (name = "input1" , value = json .dumps ({"src" : "hda" , "id" : None }))]
116+
92117 strict = model .SerializationOptions (for_edit = True )
93118 try :
94- strict . get_identifier_for_id (id_encoder = None , obj_id = None )
119+ job . _serialize (id_encoder = None , serialization_options = strict )
95120 except NotImplementedError :
96121 pass
97122 else :
98- raise AssertionError ("strict mode should have raised on null obj_id " )
123+ raise AssertionError ("strict mode should have raised on null param id " )
99124
100125 tolerant = model .SerializationOptions (for_edit = True , tolerate_missing_data = True )
101- assert tolerant .get_identifier_for_id (id_encoder = None , obj_id = None ) is None
102- assert tolerant .get_identifier_for_id (id_encoder = None , obj_id = 0 ) == 0
103- assert tolerant .get_identifier_for_id (id_encoder = None , obj_id = 42 ) == 42
126+ rval = job ._serialize (id_encoder = None , serialization_options = tolerant )
127+ assert rval ["params" ]["input1" ] == {"src" : "hda" , "id" : None }
128+ assert rval ["id" ] == 42
129+ assert rval ["tool_id" ] == "cat1"
0 commit comments