From b5f495a52d39561e17d53d8bdfd41f6ffe99e90a Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Fri, 21 Jan 2022 12:30:31 +0100
Subject: [PATCH] TMSS-671: fixed test

---
 .../services/scheduling/test/t_dynamic_scheduling.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 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 49abb0b8cb9..fee5838d442 100755
--- a/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py
+++ b/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py
@@ -810,7 +810,7 @@ class TestDynamicScheduling(BaseDynamicSchedulingTestCase):
         self.assertEqual(scheduled_scheduling_unit.status.value, 'scheduled')
         self.assertEqual(scheduled_scheduling_unit.scheduled_start_time, at)
 
-    @unittest.skip("FIX TEST, skipping it for now, see TODO comment in assign_start_stop_times_to_schedulable_scheduling_units")
+
     def test_three_simple_observations_no_constraints_different_project_priority(self):
         scheduling_unit_draft_low = self.create_simple_observation_scheduling_unit("scheduling unit low", scheduling_set=self.scheduling_set_low)
         scheduling_unit_blueprint_low = create_scheduling_unit_blueprint_and_tasks_and_subtasks_from_scheduling_unit_draft(scheduling_unit_draft_low)
@@ -830,20 +830,20 @@ class TestDynamicScheduling(BaseDynamicSchedulingTestCase):
 
         # check the results
         # we expect the sub_high to be scheduled
-        scheduling_unit_blueprint_low.refresh_from_db()
-        scheduling_unit_blueprint_medium.refresh_from_db()
-        scheduling_unit_blueprint_high.refresh_from_db()
+        scheduling_unit_blueprint_high = wait_for_scheduling_unit_blueprint_status(scheduling_unit_blueprint_high.id, models.SchedulingUnitStatus.Choices.SCHEDULED.value)
+        scheduling_unit_blueprint_medium = wait_for_scheduling_unit_blueprint_status(scheduling_unit_blueprint_medium.id, models.SchedulingUnitStatus.Choices.SCHEDULABLE.value)
+        scheduling_unit_blueprint_low = wait_for_scheduling_unit_blueprint_status(scheduling_unit_blueprint_low.id, models.SchedulingUnitStatus.Choices.SCHEDULABLE.value)
         self.assertEqual(scheduling_unit_blueprint_low.status.value, 'schedulable')
         self.assertEqual(scheduling_unit_blueprint_medium.status.value, 'schedulable')
         self.assertEqual(scheduling_unit_blueprint_high.status.value, 'scheduled')
 
         # check the scheduled subtask
         upcoming_scheduled_subtasks = models.Subtask.objects.filter(state__value='scheduled',
-                                                                    task_blueprints__scheduling_unit_blueprint__in=(scheduling_unit_blueprint_low,
+                                                                    task_blueprint__scheduling_unit_blueprint__in=(scheduling_unit_blueprint_low,
                                                                                                                    scheduling_unit_blueprint_medium,
                                                                                                                    scheduling_unit_blueprint_high)).all()
         self.assertEqual(1, upcoming_scheduled_subtasks.count())
-        self.assertEqual(scheduling_unit_blueprint_high.id, upcoming_scheduled_subtasks[0].task_blueprints().first().scheduling_unit_blueprint_cs001.id)  # all task blueprints share same SU, so it does not matter which one we check
+        self.assertEqual(scheduling_unit_blueprint_high.id, upcoming_scheduled_subtasks[0].task_blueprint.scheduling_unit_blueprint.id)
 
         # check scheduling_unit_blueprint_low starts after the scheduled scheduling_unit_blueprint_high
         self.assertGreater(scheduling_unit_blueprint_low.scheduled_start_time, scheduling_unit_blueprint_medium.scheduled_start_time)
-- 
GitLab