def test_cant_save_due_to_overlap(self): overlapping_entry = TimelineEntry( teacher=self.teacher, lesson=self.lesson, start=self.tzdatetime(2016, 1, 3, 4, 0), end=self.tzdatetime(2016, 1, 3, 4, 30), ) with self.assertRaises(AutoScheduleExpcetion): # should conflict with self.big_entry overlapping_entry.clean()
def test_no_validation_when_more_then_one_student_has_signed(self): """ There is no need to validate a timeline entry when it has students """ overlapping_entry = TimelineEntry( teacher=self.teacher, lesson=self.lesson, start=self.tzdatetime(2016, 1, 3, 4, 0), end=self.tzdatetime(2016, 1, 3, 4, 30), taken_slots=1, ) overlapping_entry.clean() # should not throw anything self.assertTrue(True)
def test_cant_save_due_to_not_fitting_working_hours(self): """ Create an entry that does not fit into teachers working hours """ entry = TimelineEntry( teacher=self.teacher, lesson=self.lesson, start=self.tzdatetime(2032, 5, 3, 13, 30), # monday end=self.tzdatetime(2032, 5, 3, 14, 0), allow_besides_working_hours=False ) with self.assertRaises(DoesNotFitWorkingHours, msg='Entry does not fit teachers working hours'): entry.clean()
def test_cant_save_due_to_teacher_has_events(self): entry = TimelineEntry( teacher=self.teacher, lesson=self.lesson, start=self.tzdatetime(2016, 5, 3, 13, 30), end=self.tzdatetime(2016, 5, 3, 14, 00), ) mixer.blend( ExternalEvent, teacher=self.teacher, start=self.tzdatetime(2016, 5, 2, 00, 00), end=self.tzdatetime(2016, 5, 5, 23, 59), ) with self.assertRaises(AutoScheduleExpcetion): entry.clean()
def test_cant_save_due_to_teacher_absence(self): entry = TimelineEntry( teacher=self.teacher, lesson=self.lesson, start=self.tzdatetime(2016, 5, 3, 13, 30), end=self.tzdatetime(2016, 5, 3, 14, 00), ) vacation = Absence( type='vacation', teacher=self.teacher, start=self.tzdatetime(2016, 5, 2, 00, 00), end=self.tzdatetime(2016, 5, 5, 23, 59), ) vacation.save() with self.assertRaises(AutoScheduleExpcetion): entry.clean()