@@ -702,16 +702,6 @@ def test_deactivation_endpoint(self):
702
702
strata = ['y' , 'o' ],
703
703
cartesian_control = True )
704
704
705
- # Assert that there are old to young transitions
706
- transition_list = []
707
- for template in age_strata .templates :
708
- if hasattr (template , 'subject' ) and hasattr (template , 'outcome' ):
709
- subj , outc = template .subject .name , template .outcome .name
710
- if subj .endswith ('_o' ) and outc .endswith ('_y' ) or \
711
- subj .endswith ('_y' ) and outc .endswith ('_o' ):
712
- transition_list .append ((subj , outc ))
713
- assert len (transition_list ), "No old to young transitions found"
714
-
715
705
amr_sir = AskeNetPetriNetModel (Model (age_strata )).to_json ()
716
706
717
707
# Test the endpoint itself
@@ -744,6 +734,15 @@ def test_deactivation_endpoint(self):
744
734
self .assertEqual (422 , response .status_code )
745
735
746
736
# Actual Test
737
+ # Assert that there are old to young transitions
738
+ transition_list = []
739
+ for template in age_strata .templates :
740
+ if hasattr (template , 'subject' ) and hasattr (template , 'outcome' ):
741
+ subj , outc = template .subject .name , template .outcome .name
742
+ if subj .endswith ('_o' ) and outc .endswith ('_y' ) or \
743
+ subj .endswith ('_y' ) and outc .endswith ('_o' ):
744
+ transition_list .append ((subj , outc ))
745
+ assert len (transition_list ), "No old to young transitions found"
747
746
response = self .client .post (
748
747
"/api/deactivate_transitions" ,
749
748
json = {"model" : amr_sir , "transitions" : transition_list }
@@ -772,10 +771,11 @@ def test_deactivation_endpoint(self):
772
771
tm_deactivated_params = template_model_from_askenet_json (
773
772
amr_sir_deactivated_params )
774
773
for template in tm_deactivated_params .templates :
775
- for symb in template .rate_law .atoms ():
776
- if str (symb ) == deactivate_key :
777
- assert (
778
- template .rate_law .rate_law .args [0 ] ==
779
- sympy .core .numbers .Zero (),
780
- template .rate_law
781
- )
774
+ # All rate laws must either be zero or not contain the deactivated
775
+ # parameter
776
+ if template .rate_law and not template .rate_law .is_zero :
777
+ for symb in template .rate_law .atoms ():
778
+ assert str (symb ) != deactivate_key
779
+ else :
780
+ assert (template .rate_law .args [0 ] == sympy .core .numbers .Zero (),
781
+ template .rate_law )
0 commit comments