@@ -182,3 +182,72 @@ def test_observable():
182182 #
183183 # with pytest.raises(ValidationError):
184184 # Observable(id="obs1", formula="observableParameter2_obs1")
185+
186+
187+ def test_change ():
188+ Change (target_id = "k1" , target_value = 1 )
189+ Change (target_id = "k1" , target_value = "x * y" )
190+
191+ assert (
192+ Change (target_id = "k1" , target_value = x * y , non_petab = "foo" ).non_petab
193+ == "foo"
194+ )
195+ with pytest .raises (ValidationError , match = "Invalid ID" ):
196+ Change (target_id = "1_k" , target_value = x )
197+
198+ with pytest .raises (ValidationError , match = "input_value=None" ):
199+ Change (target_id = "k1" , target_value = None )
200+
201+
202+ def test_period ():
203+ ExperimentPeriod (time = 0 )
204+ ExperimentPeriod (time = 1 , condition_id = "p1" )
205+ ExperimentPeriod (time = "-inf" , condition_id = "p1" )
206+
207+ assert (
208+ ExperimentPeriod (time = "1" , condition_id = "p1" , non_petab = 1 ).non_petab
209+ == 1
210+ )
211+
212+ with pytest .raises (ValidationError , match = "got inf" ):
213+ ExperimentPeriod (time = "inf" , condition_id = "p1" )
214+
215+ with pytest .raises (ValidationError , match = "Invalid ID" ):
216+ ExperimentPeriod (time = 1 , condition_id = "1_condition" )
217+
218+ with pytest .raises (ValidationError , match = "type=missing" ):
219+ ExperimentPeriod (condition_id = "condition" )
220+
221+
222+ def test_parameter ():
223+ Parameter (id = "k1" , lb = 1 , ub = 2 )
224+ Parameter (id = "k1" , estimate = False , nominal_value = 1 )
225+
226+ assert Parameter (id = "k1" , lb = 1 , ub = 2 , non_petab = 1 ).non_petab == 1
227+
228+ with pytest .raises (ValidationError , match = "Invalid ID" ):
229+ Parameter (id = "1_k" , lb = 1 , ub = 2 )
230+
231+ with pytest .raises (ValidationError , match = "upper" ):
232+ Parameter (id = "k1" , lb = 1 )
233+
234+ with pytest .raises (ValidationError , match = "lower" ):
235+ Parameter (id = "k1" , ub = 1 )
236+
237+ with pytest .raises (ValidationError , match = "less than" ):
238+ Parameter (id = "k1" , lb = 2 , ub = 1 )
239+
240+
241+ def test_experiment ():
242+ Experiment (id = "experiment1" )
243+ Experiment (
244+ id = "experiment1" , periods = [ExperimentPeriod (time = 1 , condition_id = "c1" )]
245+ )
246+
247+ assert Experiment (id = "experiment1" , non_petab = 1 ).non_petab == 1
248+
249+ with pytest .raises (ValidationError , match = "Field required" ):
250+ Experiment ()
251+
252+ with pytest .raises (ValidationError , match = "Invalid ID" ):
253+ Experiment (id = "experiment 1" )
0 commit comments