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 82bd9243e1897bd246367eb96ebb97f88dc927a5..77e62b3c4a2b4a9505563747c6f78c5c9fb1eaa9 100755 --- a/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py +++ b/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py @@ -426,7 +426,7 @@ class TestDailyConstraints(TestCase): # require_day def test_get_earliest_possible_start_time_with_daytime_constraint_returns_day_start(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_day'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_day'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data_early_night timestamp = datetime(2020, 1, 1, 4, 0, 0) @@ -435,7 +435,7 @@ class TestDailyConstraints(TestCase): def test_get_earliest_possible_start_time_with_daytime_constraint_returns_day_start_of_latest_station(self): self.scheduling_unit_blueprint.requirements_doc['tasks']['Observation']['specifications_doc']['station_groups'] = [{'stations': ['CS001', 'DE601']}] - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_day'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_day'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data_early_night timestamp = datetime(2020, 1, 1, 4, 0, 0) @@ -443,28 +443,28 @@ class TestDailyConstraints(TestCase): self.assertEqual(returned_time, self.sunrise_data['DE601']['day'][0]['start']) def test_get_earliest_possible_start_time_with_daytime_constraint_returns_timestamp(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_day'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_day'] = True self.scheduling_unit_blueprint.save() timestamp = datetime(2020, 1, 1, 10, 0, 0) returned_time = get_earliest_possible_start_time(self.scheduling_unit_blueprint, timestamp) self.assertEqual(returned_time, timestamp) def test_get_earliest_possible_start_time_with_daytime_constraint_returns_next_day_start(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_day'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_day'] = True self.scheduling_unit_blueprint.save() timestamp = datetime(2020, 1, 1, 20, 0, 0) returned_time = get_earliest_possible_start_time(self.scheduling_unit_blueprint, timestamp) self.assertEqual(returned_time, self.sunrise_data['CS001']['day'][1]['start']) def test_get_earliest_possible_start_time_with_daytime_constraint_returns_next_day_start_when_obs_does_not_fit(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_day'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_day'] = True self.scheduling_unit_blueprint.save() timestamp = datetime(2020, 1, 1, 14, 0, 0) returned_time = get_earliest_possible_start_time(self.scheduling_unit_blueprint, timestamp) self.assertEqual(returned_time, self.sunrise_data['CS001']['day'][1]['start']) def test_can_run_anywhere_within_timewindow_with_daily_constraints_with_daytime_constraint_returns_true(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_day'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_day'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data_late_night_late_night @@ -473,7 +473,7 @@ class TestDailyConstraints(TestCase): self.assertTrue(tc1.can_run_anywhere_within_timewindow_with_daily_constraints(self.scheduling_unit_blueprint, lower_bound, upper_bound)) def test_can_run_anywhere_within_timewindow_with_daily_constraints_with_daytime_constraint_returns_false_when_not_daytime(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_day'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_day'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data_late_night_late_night @@ -482,7 +482,7 @@ class TestDailyConstraints(TestCase): self.assertFalse(tc1.can_run_anywhere_within_timewindow_with_daily_constraints(self.scheduling_unit_blueprint, lower_bound, upper_bound)) def test_can_run_anywhere_within_timewindow_with_daily_constraints_with_daytime_constraint_returns_false_when_partially_not_daytime(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_day'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_day'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data_late_night_late_night @@ -498,10 +498,10 @@ class TestDailyConstraints(TestCase): def test_can_run_within_timewindow_with_daytime_constraint_returns_correct_value(self): # todo: for time ranges across dates, consider removing the mock for this because the moving window cannot be easily mocked # remove other constraints: - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {} + self.scheduling_unit_blueprint.scheduling_constraints_doc['sky'] = {} # set constraint to test - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_day'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_day'] = True self.scheduling_unit_blueprint.save() # can run in day @@ -519,7 +519,7 @@ class TestDailyConstraints(TestCase): # require_night def test_get_earliest_possible_start_time_with_nighttime_constraint_returns_night_start(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_night'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_night'] = True self.scheduling_unit_blueprint.save() timestamp = datetime(2020, 1, 1, 14, 0, 0) returned_time = get_earliest_possible_start_time(self.scheduling_unit_blueprint, timestamp) @@ -527,14 +527,14 @@ class TestDailyConstraints(TestCase): def test_get_earliest_possible_start_time_with_nighttime_constraint_returns_night_start_of_latest_station(self): self.scheduling_unit_blueprint.requirements_doc['tasks']['Observation']['specifications_doc']['station_groups'] = [{'stations': ['CS001', 'DE601']}] - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_night'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_night'] = True self.scheduling_unit_blueprint.save() timestamp = datetime(2020, 1, 1, 14, 0, 0) returned_time = get_earliest_possible_start_time(self.scheduling_unit_blueprint, timestamp) self.assertEqual(returned_time, self.sunrise_data['DE601']['night'][0]['start']) def test_get_earliest_possible_start_time_with_nighttime_constraint_returns_timestamp(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_night'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_night'] = True self.scheduling_unit_blueprint.save() # late night @@ -549,7 +549,7 @@ class TestDailyConstraints(TestCase): self.assertEqual(returned_time, timestamp) def test_get_earliest_possible_start_time_with_nighttime_constraint_returns_next_night_start_when_obs_does_not_fit(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_night'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_night'] = True self.scheduling_unit_blueprint.save() # early night @@ -559,7 +559,7 @@ class TestDailyConstraints(TestCase): self.assertEqual(returned_time, self.sunrise_data_early_night['CS001']['night'][1]['start']) def test_can_run_anywhere_within_timewindow_with_daily_constraints_with_nighttime_constraint_returns_true(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_night'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_night'] = True self.scheduling_unit_blueprint.save() # early night @@ -581,7 +581,7 @@ class TestDailyConstraints(TestCase): self.assertTrue(tc1.can_run_anywhere_within_timewindow_with_daily_constraints(self.scheduling_unit_blueprint, lower_bound, upper_bound)) def test_can_run_anywhere_within_timewindow_with_daily_constraints_with_nighttime_constraint_returns_false_when_not_nighttime(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_night'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_night'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data_late_night_late_night @@ -590,7 +590,7 @@ class TestDailyConstraints(TestCase): self.assertFalse(tc1.can_run_anywhere_within_timewindow_with_daily_constraints(self.scheduling_unit_blueprint, lower_bound, upper_bound)) def test_can_run_anywhere_within_timewindow_with_daily_constraints_with_nighttime_constraint_returns_false_when_partially_not_nighttime(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_night'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_night'] = True self.scheduling_unit_blueprint.save() # night-day next day @@ -632,10 +632,10 @@ class TestDailyConstraints(TestCase): def test_can_run_within_timewindow_with_nighttime_constraint_returns_correct_value(self): # todo: for time ranges across dates, consider removing the mock for this because the moving window cannot be easily mocked # remove other constraints: - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {} + self.scheduling_unit_blueprint.scheduling_constraints_doc['sky'] = {} # set constraint to test - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['require_night'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['require_night'] = True self.scheduling_unit_blueprint.save() # cannot run in day @@ -654,7 +654,7 @@ class TestDailyConstraints(TestCase): # avoid_twilight def test_get_earliest_possible_start_time_with_twilight_constraint_returns_day_start(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['avoid_twilight'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['avoid_twilight'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data_early_night @@ -664,7 +664,7 @@ class TestDailyConstraints(TestCase): def test_get_earliest_possible_start_time_with_twilight_constraint_returns_day_start_of_latest_station(self): self.scheduling_unit_blueprint.requirements_doc['tasks']['Observation']['specifications_doc']['station_groups'] = [{'stations': ['CS001', 'DE601']}] - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['avoid_twilight'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['avoid_twilight'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data_early_night @@ -673,7 +673,7 @@ class TestDailyConstraints(TestCase): self.assertEqual(returned_time, self.sunrise_data['DE601']['day'][0]['start']) def test_get_earliest_possible_start_time_with_twilight_constraint_returns_night_start(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['avoid_twilight'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['avoid_twilight'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data @@ -683,7 +683,7 @@ class TestDailyConstraints(TestCase): def test_get_earliest_possible_start_time_with_twilight_constraint_returns_night_start_of_latest_station(self): self.scheduling_unit_blueprint.requirements_doc['tasks']['Observation']['specifications_doc']['station_groups'] = [{'stations': ['CS001', 'DE601']}] - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['avoid_twilight'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['avoid_twilight'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data @@ -692,7 +692,7 @@ class TestDailyConstraints(TestCase): self.assertEqual(returned_time, self.sunrise_data['DE601']['night'][0]['start']) def test_get_earliest_possible_start_time_with_twilight_constraint_returns_timestamp(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['avoid_twilight'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['avoid_twilight'] = True self.scheduling_unit_blueprint.save() # daytime @@ -712,7 +712,7 @@ class TestDailyConstraints(TestCase): self.assertEqual(returned_time, timestamp) def test_get_earliest_possible_start_time_with_twilight_constraint_returns_day_or_night_start_when_obs_does_not_fit(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['avoid_twilight'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['avoid_twilight'] = True self.scheduling_unit_blueprint.save() timestamp = datetime(2020, 1, 1, 15, 0, 0) @@ -725,7 +725,7 @@ class TestDailyConstraints(TestCase): self.assertEqual(returned_time, self.sunrise_data['CS001']['day'][0]['start']) def test_can_run_anywhere_within_timewindow_with_daily_constraints_with_twilight_constraint_returns_true(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['avoid_twilight'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['avoid_twilight'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data_late_night_late_night @@ -734,7 +734,7 @@ class TestDailyConstraints(TestCase): self.assertTrue(tc1.can_run_anywhere_within_timewindow_with_daily_constraints(self.scheduling_unit_blueprint, lower_bound, upper_bound)) def test_can_run_anywhere_within_timewindow_with_daily_constraints_with_twilight_constraint_returns_false_when_in_twilight(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['avoid_twilight'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['avoid_twilight'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data_late_night_late_night @@ -748,7 +748,7 @@ class TestDailyConstraints(TestCase): self.assertFalse(tc1.can_run_anywhere_within_timewindow_with_daily_constraints(self.scheduling_unit_blueprint, lower_bound, upper_bound)) def test_can_run_anywhere_within_timewindow_with_daily_constraints_with_twilight_constraint_returns_false_when_partially_in_twilight(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['avoid_twilight'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['avoid_twilight'] = True self.scheduling_unit_blueprint.save() self.sunrise_mock.return_value = self.sunrise_data_late_night_late_night @@ -764,10 +764,10 @@ class TestDailyConstraints(TestCase): def test_can_run_within_timewindow_with_twilight_constraint_returns_correct_value(self): # todo: for time ranges across dates, consider removing the mock for this because the moving window cannot be easily mocked # remove other constraints: - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {} + self.scheduling_unit_blueprint.scheduling_constraints_doc['sky'] = {} # set constraint to test - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['daily']['avoid_twilight'] = True + self.scheduling_unit_blueprint.scheduling_constraints_doc['daily']['avoid_twilight'] = True self.scheduling_unit_blueprint.save() # can run in day @@ -821,14 +821,14 @@ class TestSkyConstraints(unittest.TestCase): # min_distance def test_can_run_anywhere_within_timewindow_with_sky_constraints_with_min_distance_constraint_returns_true_when_met(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'min_distance': {'sun': 0.1, 'moon': 0.1, 'jupiter': 0.1}} + self.scheduling_unit_blueprint.scheduling_constraints_doc['sky'] = {'min_distance': {'sun': 0.1, 'moon': 0.1, 'jupiter': 0.1}} self.scheduling_unit_blueprint.save() timestamp = datetime(2020, 1, 1, 10, 0, 0) returned_value = tc1.can_run_anywhere_within_timewindow_with_sky_constraints(self.scheduling_unit_blueprint, timestamp, timestamp + timedelta(seconds=self.obs_duration)) self.assertTrue(returned_value) def test_can_run_anywhere_within_timewindow_with_sky_constraints_with_min_distance_constraint_returns_false_when_not_met(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'min_distance': {'sun': 0.2, 'moon': 0.2, 'jupiter': 0.2}} + self.scheduling_unit_blueprint.scheduling_constraints_doc['sky'] = {'min_distance': {'sun': 0.2, 'moon': 0.2, 'jupiter': 0.2}} self.scheduling_unit_blueprint.save() timestamp = datetime(2020, 1, 1, 10, 0, 0) returned_value = tc1.can_run_anywhere_within_timewindow_with_sky_constraints(self.scheduling_unit_blueprint, timestamp, timestamp + timedelta(seconds=self.obs_duration)) @@ -837,14 +837,14 @@ class TestSkyConstraints(unittest.TestCase): # min_target_elevation def test_can_run_anywhere_within_timewindow_with_sky_constraints_with_min_target_elevation_constraint_returns_true_when_met(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'min_target_elevation': 0.1} + self.scheduling_unit_blueprint.scheduling_constraints_doc['sky'] = {'min_target_elevation': 0.1} self.scheduling_unit_blueprint.save() timestamp = datetime(2020, 1, 1, 10, 0, 0) returned_value = tc1.can_run_anywhere_within_timewindow_with_sky_constraints(self.scheduling_unit_blueprint, timestamp, timestamp + timedelta(seconds=self.obs_duration)) self.assertTrue(returned_value) def test_can_run_anywhere_within_timewindow_with_sky_constraints_with_min_target_elevation_constraint_returns_false_when_not_met(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'min_target_elevation': 0.2} + self.scheduling_unit_blueprint.scheduling_constraints_doc['sky'] = {'min_target_elevation': 0.2} self.scheduling_unit_blueprint.save() timestamp = datetime(2020, 1, 1, 11, 0, 0) returned_value = tc1.can_run_anywhere_within_timewindow_with_sky_constraints(self.scheduling_unit_blueprint, timestamp, timestamp + timedelta(seconds=self.obs_duration)) @@ -863,28 +863,28 @@ class TestTimeConstraints(TestCase): """ def add_time_at_constraint(self, at_timestamp): - lst_at_constraint = self.scheduling_unit_blueprint.draft.scheduling_constraints_doc + lst_at_constraint = self.scheduling_unit_blueprint.scheduling_constraints_doc lst_at_constraint['time']['at'] = at_timestamp.isoformat() self.scheduling_unit_blueprint.save() def add_time_between_constraint(self, from_timestamp, to_timestamp): - lst_between_constraints = self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["between"] + lst_between_constraints = self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["between"] time_constraint_dict = {"from": from_timestamp.isoformat(), "to": to_timestamp.isoformat()} lst_between_constraints.append(time_constraint_dict) self.scheduling_unit_blueprint.save() def add_time_not_between_constraint(self, from_timestamp, to_timestamp): - lst_between_constraints = self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["not_between"] + lst_between_constraints = self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["not_between"] time_constraint_dict = {"from": from_timestamp.isoformat(), "to": to_timestamp.isoformat()} lst_between_constraints.append(time_constraint_dict) self.scheduling_unit_blueprint.save() def clear_time_constraints(self): - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["between"] = [] - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["not_between"] = [] - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time'].pop('at', None) - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time'].pop("before", None) - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time'].pop('after', None) + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["between"] = [] + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["not_between"] = [] + self.scheduling_unit_blueprint.scheduling_constraints_doc['time'].pop('at', None) + self.scheduling_unit_blueprint.scheduling_constraints_doc['time'].pop("before", None) + self.scheduling_unit_blueprint.scheduling_constraints_doc['time'].pop('after', None) def setUp(self) -> None: # scheduling unit @@ -902,7 +902,7 @@ class TestTimeConstraints(TestCase): # Set datetime constraints before lower_bound self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 11, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 11, 0, 0).isoformat() self.assertTrue(tc1.can_run_anywhere_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) @@ -911,28 +911,28 @@ class TestTimeConstraints(TestCase): # Set datetime constraints equal to lower_bound self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 12, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 12, 0, 0).isoformat() self.assertFalse(tc1.can_run_anywhere_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) # Set datetime constraints after lower_bound self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() self.assertFalse(tc1.can_run_anywhere_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) # Set datetime constraints to upper_bound self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 2, 12, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 2, 12, 0, 0).isoformat() self.assertFalse(tc1.can_run_anywhere_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) # Set datetime constraints after upper_bound self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 2, 13, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 2, 13, 0, 0).isoformat() self.assertFalse(tc1.can_run_anywhere_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) @@ -941,14 +941,14 @@ class TestTimeConstraints(TestCase): # Set datetime constraints before lower bounds, but with too short window for obs duration self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 11, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 11, 0, 0).isoformat() 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, 13, 0, 0))) # Set datetime constraints after lower bounds, and with too little space left in window for obs duration self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 14, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 14, 0, 0).isoformat() 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, 15, 0, 0))) @@ -957,14 +957,14 @@ class TestTimeConstraints(TestCase): # Set datetime constraints before lower bounds, and with sufficient window for obs duration self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 11, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 11, 0, 0).isoformat() self.assertTrue(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 constraints after lower bounds, but with sufficient space left in window for obs duration self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() self.assertTrue(tc1.can_run_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 1, 16, 0, 0))) @@ -975,27 +975,27 @@ class TestTimeConstraints(TestCase): # Set datetime constraints before lower_bound self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 11, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 11, 0, 0).isoformat() self.assertFalse(tc1.can_run_anywhere_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) # Set datetime constraints equal to lower_bound self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 12, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 12, 0, 0).isoformat() self.assertFalse(tc1.can_run_anywhere_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) # Set datetime constraints after lower_bound self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() self.assertFalse(tc1.can_run_anywhere_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) # Set datetime constraints equal to upper_bound self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 12, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 12, 0, 0).isoformat() self.assertFalse(tc1.can_run_anywhere_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) @@ -1005,7 +1005,7 @@ class TestTimeConstraints(TestCase): # Set datetime constraints after upper_bound self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 13, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 13, 0, 0).isoformat() self.assertTrue(tc1.can_run_anywhere_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) @@ -1014,14 +1014,14 @@ class TestTimeConstraints(TestCase): # Set datetime constraints after upper bound, but with too short window for obs duration self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 13, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 13, 0, 0).isoformat() self.assertFalse(tc1.can_run_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 2, 11, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) # Set datetime constraints after lower bound, and with too little space left in window for obs duration self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() self.assertFalse(tc1.can_run_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) @@ -1030,14 +1030,14 @@ class TestTimeConstraints(TestCase): # Set datetime constraints after upper bounds, and with sufficient window for obs duration self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 13, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 13, 0, 0).isoformat() self.assertTrue(tc1.can_run_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) # Set datetime constraints after lower bounds, but with sufficient space left in window for obs duration self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 15, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 15, 0, 0).isoformat() self.assertTrue(tc1.can_run_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint, datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 12, 0, 0))) @@ -1318,22 +1318,22 @@ class TestTimeConstraints(TestCase): # Set before and after constraint with sufficient gap to fit observation, and assert True self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 12, 59, 59).isoformat() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 15, 0, 1).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 12, 59, 59).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 15, 0, 1).isoformat() self.assertTrue(self.execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary()) # set before and after constraint with slightly smaller gap for observation, and assert False self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 15, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 1, 15, 0, 0).isoformat() self.assertFalse(self.execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary()) # set before and after constraint with large gap # then and add additional between and not between constraints until window is blocked # can run 13-8h self.clear_time_constraints() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 8, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["after"] = datetime(2020, 1, 1, 13, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 8, 0, 0).isoformat() self.assertTrue(self.execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary()) # can run 13h-20h @@ -1353,7 +1353,7 @@ class TestTimeConstraints(TestCase): self.assertTrue(self.execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary()) # move before constraint, can not run anymore - self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 5, 0, 0).isoformat() + self.scheduling_unit_blueprint.scheduling_constraints_doc['time']["before"] = datetime(2020, 1, 2, 5, 0, 0).isoformat() self.assertFalse(self.execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary())