Skip to content
Snippets Groups Projects
Commit 43b8d9fb authored by Jörn Künsemöller's avatar Jörn Künsemöller
Browse files

TMSS-605: ass more test cases to verify time filter

parent 0a1f09c0
No related branches found
No related tags found
2 merge requests!634WIP: COBALT commissioning delta,!624TMSS-605: Add check for stations in use when saving reservation, and fix...
......@@ -255,15 +255,51 @@ class TestStationReservations(unittest.TestCase):
task_spec['station_groups'] = [{'stations': ['CS001', 'RS205'], 'max_nr_missing': 0}]
scheduling_unit_blueprint = models.SchedulingUnitBlueprint.objects.create(**SchedulingUnitBlueprint_test_data(specifications_template=models.SchedulingUnitTemplate.objects.get(name='scheduling unit')))
task_blueprint = models.TaskBlueprint.objects.create(**TaskBlueprint_test_data(specifications_template=task_template, scheduling_unit_blueprint=scheduling_unit_blueprint, specifications_doc=task_spec))
subtask = models.Subtask.objects.create(**Subtask_test_data(subtask_template=subtask_template, specifications_doc=spec, task_blueprint=task_blueprint))
subtask = models.Subtask.objects.create(**Subtask_test_data(subtask_template=subtask_template, specifications_doc=spec, task_blueprint=task_blueprint,
scheduled_on_sky_start_time=datetime(2020, 1, 1, 10, 0, 0), scheduled_on_sky_stop_time=datetime(2020, 1, 1, 14, 0, 0)))
set_subtask_state_following_allowed_transitions(subtask, "started")
# try to create a reservation and assert failure
# try to create a reservation that overlaps with the subtask and assert failure
#
# full overlap
with self.assertRaises(ValueError) as context:
self.create_station_reservation("my-reservation", ["CS002", "RS205", "DE609"], datetime(2020, 1, 1, 0, 0, 0), datetime(2020, 1, 2, 0, 0, 0))
self.create_station_reservation("my-reservation-long", ["CS002", "RS205", "DE609"], datetime(2020, 1, 1, 0, 0, 0), datetime(2020, 1, 2, 0, 0, 0))
self.assertIn("Station(s) ['RS205'] cannot be reserved", str(context.exception))
self.assertIn(scheduling_unit_blueprint.name, str(context.exception))
with self.assertRaises(ValueError) as context:
self.create_station_reservation("my-reservation-short", ["CS002", "RS205", "DE609"], datetime(2020, 1, 1, 11, 0, 0), datetime(2020, 1, 1, 13, 0, 0))
self.assertIn("Station(s) ['RS205'] cannot be reserved", str(context.exception))
self.assertIn(scheduling_unit_blueprint.name, str(context.exception))
# partial overlap
with self.assertRaises(ValueError) as context:
self.create_station_reservation("my-reservation-early", ["CS002", "RS205", "DE609"], datetime(2020, 1, 1, 0, 0, 0), datetime(2020, 1, 1, 12, 0, 0))
self.assertIn("Station(s) ['RS205'] cannot be reserved", str(context.exception))
self.assertIn(scheduling_unit_blueprint.name, str(context.exception))
with self.assertRaises(ValueError) as context:
self.create_station_reservation("my-reservation-late", ["CS002", "RS205", "DE609"], datetime(2020, 1, 1, 12, 0, 0), datetime(2020, 1, 2, 0, 0, 0))
self.assertIn("Station(s) ['RS205'] cannot be reserved", str(context.exception))
self.assertIn(scheduling_unit_blueprint.name, str(context.exception))
# open end
with self.assertRaises(ValueError) as context:
self.create_station_reservation("my-reservation-open-end", ["CS002", "RS205", "DE609"], datetime(2020, 1, 1, 0, 0, 0))
self.assertIn("Station(s) ['RS205'] cannot be reserved", str(context.exception))
self.assertIn(scheduling_unit_blueprint.name, str(context.exception))
# assert that it works before or after the subtask
#
# before
self.create_station_reservation("my-reservation-before", ["CS002", "RS205", "DE609"], datetime(2020, 1, 1, 0, 0, 0), datetime(2020, 1, 1, 9, 0, 0))
# after
self.create_station_reservation("my-reservation-after", ["CS002", "RS205", "DE609"], datetime(2020, 1, 1, 15, 0, 0), datetime(2020, 1, 2, 0, 0, 0))
# after, open end
self.create_station_reservation("my-reservation-open-end", ["CS002", "RS205", "DE609"], datetime(2020, 1, 1, 15, 0, 0))
class CreationFromReservationStrategyTemplate(unittest.TestCase):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment