From 426cf3ce66a805a53d4bf96e2a2463d207dd7b12 Mon Sep 17 00:00:00 2001 From: Mario Raciti <mario.raciti@inaf.it> Date: Mon, 15 Mar 2021 16:28:24 +0100 Subject: [PATCH] TMSS-672: Add more tests for the 'at' constraint --- .../scheduling/test/t_dynamic_scheduling.py | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py b/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py index 7b970c4a52f..8c799b54238 100755 --- a/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py +++ b/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py @@ -1103,7 +1103,7 @@ class TestTimeConstraints(TestCase): def test_can_run_within_at_constraint(self): """ - Test "at" constraint + Test "at" constraint with both boundary and 'inside' upper_bound and lower_bound """ # no constraints defined so should be OK self.clear_time_constraints() @@ -1123,13 +1123,35 @@ class TestTimeConstraints(TestCase): datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 1, 14, 0, 0))) + # Set datetime constraint at upper_bound + self.clear_time_constraints() + self.add_time_at_constraint(datetime(2020, 1, 1, 14, 0, 0)) + self.assertFalse(tc1.can_run_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, + datetime(2020, 1, 1, 12, 0, 0), + datetime(2020, 1, 1, 14, 0, 0))) + # Set datetime constraint after upper_bound self.clear_time_constraints() - self.add_time_at_constraint(datetime(2020, 1, 2, 15, 0, 0)) + self.add_time_at_constraint(datetime(2020, 1, 1, 15, 0, 0)) self.assertFalse(tc1.can_run_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 1, 14, 0, 0))) + # Set datetime constraint at lower_bound + self.clear_time_constraints() + self.add_time_at_constraint(datetime(2020, 1, 1, 12, 0, 0)) + self.assertTrue(self.execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary()) + + # Set datetime constraint that fits the time window + self.clear_time_constraints() + self.add_time_at_constraint(datetime(2020, 1, 1, 18, 30, 0)) + self.assertTrue(self.execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary()) + + # Set datetime constraint so that obs lasts till exactly upper_bound + self.clear_time_constraints() + self.add_time_at_constraint(datetime(2020, 1, 2, 9, 50, 0)) + self.assertTrue(self.execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary()) + def test_can_run_within_between_constraints(self): """ Test multiple 'between' constraints within 24 boundary and check overall result of -- GitLab