Skip to content

Commit 0f0dff2

Browse files
committed
Update test
1 parent c804111 commit 0f0dff2

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tests/test_model_api.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -702,16 +702,6 @@ def test_deactivation_endpoint(self):
702702
strata=['y', 'o'],
703703
cartesian_control=True)
704704

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-
715705
amr_sir = AskeNetPetriNetModel(Model(age_strata)).to_json()
716706

717707
# Test the endpoint itself
@@ -744,6 +734,15 @@ def test_deactivation_endpoint(self):
744734
self.assertEqual(422, response.status_code)
745735

746736
# 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"
747746
response = self.client.post(
748747
"/api/deactivate_transitions",
749748
json={"model": amr_sir, "transitions": transition_list}
@@ -772,10 +771,11 @@ def test_deactivation_endpoint(self):
772771
tm_deactivated_params = template_model_from_askenet_json(
773772
amr_sir_deactivated_params)
774773
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

Comments
 (0)