diff --git a/SAS/TMSS/backend/test/t_scheduling_units.py b/SAS/TMSS/backend/test/t_scheduling_units.py index eae6c80a46e0d7bae42b754664016b07ef01357c..47612c53b51775e43c7a80854afdb8a7dcd11560 100644 --- a/SAS/TMSS/backend/test/t_scheduling_units.py +++ b/SAS/TMSS/backend/test/t_scheduling_units.py @@ -54,7 +54,7 @@ from lofar.sas.tmss.test.tmss_test_data_django_models import * rest_data_creator = tmss_test_env.create_test_data_creator() from lofar.sas.tmss.tmss.tmssapp import models -from lofar.sas.tmss.tmss.exceptions import SchemaValidationException, ObsoleteTemplateException +from lofar.sas.tmss.tmss.exceptions import SchemaValidationException, ObsoleteTemplateException, ValidationException import requests @@ -393,7 +393,7 @@ class TestFlatStations(unittest.TestCase): target_obs_task = self.scheduling_unit_draft.task_drafts.get(name='Target Observation') station_groups = target_obs_task.specifications_doc['station_configuration']['station_groups'] station_groups[station_group_idx]["stations"] = lst_stations - station_groups[station_group_idx]["max_nr_missing"] = len(lst_stations) + station_groups[station_group_idx]["max_nr_missing"] = len(lst_stations)-1 target_obs_task.save() def setUp(self) -> None: @@ -409,13 +409,11 @@ class TestFlatStations(unittest.TestCase): list_expected_stations = ["CS001", "CS002", "CS003", "CS004", "CS005", "CS006", "CS007", "CS011", "CS013", "CS017", "CS021", "CS024", "CS026", "CS028", "CS030", "CS031", "CS032", "CS101", "CS103", "CS201", "CS301", "CS302", "CS401", "CS501", "RS106", "RS205", "RS208", "RS210", "RS305", "RS306", "RS307", "RS310", "RS406", "RS407", "RS409", "RS503", "RS508", "RS509", "DE601", "DE602", "DE603", "DE604", "DE605", "DE609", "FR606", "SE607", "UK608", "PL610", "PL611", "PL612", "IE613", "LV614"] self.assertCountEqual(list_expected_stations, self.scheduling_unit_blueprint.flat_station_list) - # Clear all stations and check that flat_station_list is empty + # Clear all stations should be forbidden, as we need at least one station nbr_station_groups = len(self.scheduling_unit_draft.specifications_doc['tasks']['Target Observation']['specifications_doc']['station_configuration']['station_groups']) for idx in range(nbr_station_groups): - self.modify_stations_in_station_group(idx, []) - scheduling_unit_blueprint = create_scheduling_unit_blueprint_from_scheduling_unit_draft(self.scheduling_unit_draft) - scheduling_unit_blueprint = update_task_blueprint_graph_from_draft(scheduling_unit_blueprint) - self.assertEqual([], scheduling_unit_blueprint.flat_station_list) + with self.assertRaises(ValidationException): + self.modify_stations_in_station_group(idx, []) # Set two stations for all station_groups, check flat_station_list contains two stations for idx in range(nbr_station_groups): @@ -686,6 +684,9 @@ class SchedulingUnitBlueprintIndirectModificationsTestCase(unittest.TestCase): ], "task_scheduling_relations": [] } + su_template = models.SchedulingUnitTemplate.get_latest("scheduling unit") + specifications_doc['$schema'] = su_template.schema['$id'] + scheduling_unit_draft = client.create_scheduling_unit_draft_from_specifications_doc("test_rerun_copy_of_failed_pipeline", "no description", scheduling_set['id'], specifications_doc) # ...and create a scheduling_unit_blueprint out of that @@ -787,6 +788,10 @@ class SchedulingUnitBlueprintIndirectModificationsTestCase(unittest.TestCase): ], "task_scheduling_relations": [] } + + su_template = models.SchedulingUnitTemplate.get_latest("scheduling unit") + specifications_doc['$schema'] = su_template.schema['$id'] + scheduling_unit_draft = client.create_scheduling_unit_draft_from_specifications_doc("test_rerun_copy_of_failed_tasks_excludes_observation", "no description", scheduling_set['id'], specifications_doc) # ...and create a scheduling_unit_blueprint out of that @@ -856,6 +861,9 @@ class SchedulingUnitBlueprintIndirectModificationsTestCase(unittest.TestCase): "task_scheduling_relations": [] } + su_template = models.SchedulingUnitTemplate.get_latest("scheduling unit") + specifications_doc['$schema'] = su_template.schema['$id'] + # create the scheduling_unit_draft scheduling_unit_draft = client.create_scheduling_unit_draft_from_specifications_doc("test_rerun_copy_of_finished_pipeline_with_different_settings", "no description", scheduling_set['id'], specifications_doc) self.assertEqual(2, len(scheduling_unit_draft['task_drafts']))