@@ -95,28 +95,36 @@ def test_injection_material_check(self):
9595
9696 self .assertEqual (expected_exception , repr (e .exception ))
9797
98- # Validate injection_materials=None
99- p = Procedures (
100- subject_id = "12345" ,
101- subject_procedures = [
102- Surgery (
103- start_date = start_date ,
104- experimenter_full_name = "Chip Munk" ,
105- procedures = [
106- RetroOrbitalInjection (
107- protocol_id = "134" ,
108- injection_materials = None ,
109- injection_volume = 1 ,
110- injection_eye = "Left" ,
111- injection_duration = 1 ,
112- recovery_time = 10 ,
113- ),
114- ],
115- )
116- ],
98+ # validate error for injection_materials=None
99+ with self .assertRaises (ValidationError ) as e :
100+ p = Procedures (
101+ subject_id = "12345" ,
102+ subject_procedures = [
103+ Surgery (
104+ start_date = start_date ,
105+ experimenter_full_name = "Chip Munk" ,
106+ procedures = [
107+ RetroOrbitalInjection (
108+ protocol_id = "134" ,
109+ injection_materials = None ,
110+ injection_volume = 1 ,
111+ injection_eye = "Left" ,
112+ injection_duration = 1 ,
113+ recovery_time = 10 ,
114+ ),
115+ ],
116+ )
117+ ],
118+ )
119+
120+ expected_exception = (
121+ "1 validation error for RetroOrbitalInjection\n "
122+ "injection_materials\n "
123+ " Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]\n "
124+ f" For further information visit https://errors.pydantic.dev/{ PYD_VERSION } /v/list_type"
117125 )
118126
119- self .assertEqual (p , Procedures . model_validate_json ( p . model_dump_json () ))
127+ self .assertEqual (expected_exception , repr ( e . exception ))
120128
121129 # Validate injection_materials is list of one ViralMaterial or NonViralMaterial item
122130
@@ -307,6 +315,18 @@ def test_coordinate_volume_validator(self):
307315 injection_angle = 1 ,
308316 injection_coordinate_depth = [0 , 1 ],
309317 injection_volume = [1 , 2 ],
318+ injection_materials = [
319+ ViralMaterial (
320+ material_type = "Virus" ,
321+ name = "AAV2-Flex-ChrimsonR" ,
322+ tars_identifiers = TarsVirusIdentifiers (
323+ virus_tars_id = "AiV222" ,
324+ plasmid_tars_alias = "AiP222" ,
325+ prep_lot_number = "VT222" ,
326+ ),
327+ titer = 2300000000 ,
328+ )
329+ ],
310330 )
311331 self .assertEqual (len (inj1 .injection_coordinate_depth ), len (inj1 .injection_volume ))
312332
0 commit comments