From af19ad7ab5fbca7613e783f44df5a99571a186aa Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Mon, 23 Oct 2023 16:26:23 +0200 Subject: [PATCH] TMSS-2823: handle RuleValidationException for too narrow transit window in test --- .../services/scheduling/test/t_dynamic_scheduling.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 9767b76eb59..dccdb7423fb 100755 --- a/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py +++ b/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py @@ -3289,6 +3289,14 @@ class TestDynamicScheduling(BaseDynamicSchedulingTestCase): } } + # the original spec from https://tmss.lofar.eu/api/scheduling_unit_blueprint/3703/specifications_doc_with_just_the_parameters is not accepted with the new validation + # so, proof that the validation works, and then adapt the spec for the rest of the test. + with self.assertRaises(RuleValidationException) as context: + su_draft = create_scheduling_unit_draft_from_observing_strategy_template(strategy_template, scheduling_set=scheduling_set, specifications_doc_overrides=spec) + self.assertTrue(str(context.exception).startswith("time between latest and earliest transit for targets in task")) + + # adapt the spec for the rest of the test. + spec['scheduling_constraints_doc']['sky']['transit_offset'] = {"from": -1800, "to": 1800} su_draft = create_scheduling_unit_draft_from_observing_strategy_template(strategy_template, scheduling_set=scheduling_set, specifications_doc_overrides=spec) su_blueprint = create_scheduling_unit_blueprint_and_tasks_and_subtasks_from_scheduling_unit_draft(su_draft) @@ -3296,7 +3304,7 @@ class TestDynamicScheduling(BaseDynamicSchedulingTestCase): # it should find this unit (and thus, in scheduler.do_dynamic_schedule it should get scheduled) best_next_schedulable_unit = self.scheduler.find_best_next_schedulable_unit([su_blueprint], datetime(2024, 2, 16), datetime(2024, 2, 17)) self.assertIsNotNone(best_next_schedulable_unit) - self.assertEqual(su_blueprint.id, best_next_schedulable_unit.id) + self.assertEqual(su_blueprint.id, best_next_schedulable_unit.scheduling_unit.id) def test_scheduling_blocks_outside_observation_window_TMSS_2298_bugfix(self): -- GitLab