Пример #1
0
    def test_remove_lecture(self):
        #test for removing a lecture from a slot that exists and is occupied
        
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        print(self.timetable)
        print('--------TEST - REMOVE-------------------After Adding Lecture-----------------')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        print(self.timetable)
        self.assertTrue(self.timetable.remove_lecture(ttslot))
        print('-----TEST REMOVE-----------------------After removing Lecture---------------')
        print(self.timetable)

        #test for removing a lecture from a slot that is empty
        self.assertFalse(self.timetable.remove_lecture(ttslot))

        #test for removing a lecture from a slot that does not exists
        self.assertFalse(self.timetable.remove_lecture( TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('7:00', '8:00'))))
Пример #2
0
    def test_swap_lectures(self):
        pass
        #Test later, not called in generator at the moment
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print(self.timetable)
Пример #3
0
    def test_room_is_free(self):
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        ttslot1 =TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('11:00', '12:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot1))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot2))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot3))
        
        self.assertFalse(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('7:00', '8:00')))
        self.assertFalse(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00')))
        self.assertFalse(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00')))
        self.assertFalse(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00')))

        self.assertTrue(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('12:00', '13:00')))
        self.assertTrue(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('13:00', '14:00')))
        self.assertTrue(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('14:00', '15:00')))
        self.assertTrue(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('15:00', '16:00')))
Пример #4
0
    def test_all_slots(self):
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('10:00', '11:00'))

        #print(self.timetable)
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print("############ Testing All Slots##############################")
        slots = self.timetable.all_slots()

        for slot in slots:
            print(slot)
Пример #5
0
    def test_has_right_neighbour(self):
        #TODO
        #Test for timetableslots that are occupied with lectures

        #test for edge cases

        #test for extreme left condition
        #test for left index out of bounds
        self.assertTrue(self.timetable.has_right_neighbour(
             TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('8:00', '9:00'))))

        #test for slot with right neighbour
        self.assertTrue(self.timetable.has_right_neighbour(
             TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('9:00', '10:00'))))
        
        #test for extreme right
        #should lack right neighbour
        self.assertFalse(self.timetable.has_right_neighbour(
             TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('16:00', '17:00'))))
        
        #test for slot not in timetable 
        self.assertFalse(self.timetable.has_right_neighbour(
             TimetableSlot('Tues', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('9:00', '10:00'))))
        
        #test for slot not in timetable
        self.assertFalse(self.timetable.has_right_neighbour(
             TimetableSlot('Mon',  Classroom('PB001', 50, 'Petroleum building'),TimeSlot('16:00', '17:00'))))
Пример #6
0
    def test_timetableslot(self):
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        self.assertEqual(self.timetable.timetableslot(ttslot.room,ttslot.time_slot),ttslot)
        ttslot1 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00', '10:00'))
        self.assertEqual(self.timetable.timetableslot(ttslot1.room,ttslot1.time_slot),ttslot1)
Пример #7
0
 def set_time_slots(self, room, time_slots):
     self.validate_time_slots()
     slots = []
     for time_slot in time_slots:
         time_table_slot = TimetableSlot(self.day, room, time_slot)
         slots.append(time_table_slot)
     self.table[room] = slots
Пример #8
0
    def test_add_lecture(self):
        pass
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('10:00', '11:00'))
        print(self.timetable)
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(
            self.timetable.timetableslot('Monday', ttslot1.room,
                                         ttslot1.time_slot).is_occupied, True)
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print(
            '############################### Add Lecture ############################'
        )
        print(self.timetable)
        self.timetable.timetable['Monday'].remove_time_table_slot(
            Classroom('LT ', 45, 'PBOO2'), TimeSlot('9:00', '10:00'))
        print(
            '####################################################################'
        )
        print(self.timetable)
        self.timetable.timetable['Monday'].move_lecture(ttslot, ttslot4)
        print(self.timetable.timetable)

        self.assertNotEqual(self.timetable.timetable['Monday'],
                            self.timetable.timetable['Tuesday'])
    def best_fit(self, lecture):
        free_slots = self._timetable.free_slots()
        
        # only slots that can hold lecture
        dest_slots = list(filter(lambda slot: self.can_hold(lecture, slot), free_slots))
        
        # TODO
        # change to get metric for obtaining the best

        if dest_slots:
            #sort the slots according to priority
            dest_slots.sort(key = lambda ttslot : self.priority(lecture,ttslot),reverse=False)
            return  dest_slots[-1] #return the last element on the list i.e the element with the highest
            #priority

        # we require merging slots to obtain a slot
        else:
            for ttslot in free_slots:
                # TODO
                # modify left_neighbours and right_neighbours function
                left = self._timetable.left_free_cont_neighbours(ttslot)  # free contiguous left neighbours of slot
                right = self._timetable.right_free_cont_neighbours(ttslot)

                all_slots = left + [ttslot] + right

                for slt in all_slots:
                    if slt.is_occupied:
                        continue

                total_duration = 0

                # determine if the combined duration of all slots can accomodate lecture
                for lslot in all_slots:
                    total_duration += lslot.time_slot.duration

                if lecture.duration <= total_duration:
                    total_duration = 0

                    dest_slots = []
                    for lslot in all_slots:
                        dest_slots.append(lslot)
                        total_duration += lslot.time_slot.duration
                        if total_duration >= lecture.duration:
                            break
                        
                        

                    #create a new temporary slot to accomodate the combination of slots
                    
                    tslot = TimeSlot(dest_slots[0].time_slot.startstr,dest_slots[-1].time_slot.endstr)
                    tempslot = TimetableSlot(dest_slots[0].day,dest_slots[0].room,tslot)

                    #remove all dest_slots from timetable
                    for slot in dest_slots:
                        self.timetable.remove_slot(slot.day,slot.room,slot.time_slot)
                    #add temp slot to timetable
                    self.timetable.insert_slot(tempslot.day,tempslot)

                    return tempslot
Пример #10
0
    def test_right_neighbours(self):
        #TODO
        #test for cases with lectures assigned to timetableslots
        
        #test for edge cases
        ttslot1 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('14:00', '15:00'))
        neighbours = [TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('15:00', '16:00')),
        TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('16:00', '17:00'))]
        self.assertEqual(self.timetable.right_neighbours(ttslot1),neighbours)

        #leftmmost slot with no right neighours
        ttslot1 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('16:00', '17:00'))
        self.assertEqual(self.timetable.right_neighbours(ttslot1),[])

        #slot not in timetable has no neighbours
        ttslot1 =   TimetableSlot('Fri', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('8:00', '9:00'))
        self.assertEqual(self.timetable.right_neighbours(ttslot1),[])
Пример #11
0
    def test_insert_time_table_slot(self):
        #TODO
        #do tests for slots  containing lectures
        #insert to the right
        room =  Classroom('LT ', 45, 'PBOO2')
        ttslot =  TimetableSlot('Mon', room,TimeSlot('17:00', '18:00'))
        self.timetable.insert_time_table_slot(ttslot)
        self.assertEqual(self.timetable.right_neighbour(TimetableSlot('Mon',room,TimeSlot('16:00', '17:00'))),ttslot)
        
        #test for inserting to the left
        room =  Classroom('LT ', 45, 'PBOO2')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('7:00', '8:00'))
        self.timetable.insert_time_table_slot(ttslot)
        self.assertEqual(self.timetable.left_neighbour(TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))),ttslot)

        #test for inserting slot that already exists 
        room =  Classroom('LT ', 45, 'PBOO2')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        self.assertFalse(self.timetable.insert_time_table_slot(ttslot),ttslot)
Пример #12
0
    def test_first_fit(self):
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))

        print('----------------First Fit-----------------------------')
        print(self.timetable.first_fit(lecture))
Пример #13
0
    def test_add_lecture(self):

        #test for the case of adding a lecture to a slot that is free with free parameter
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        print(self.timetable)
        print('---------------------------After Adding Lecture-----------------')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        print(self.timetable)

        #test for the case of adding a lecture to a slot that is not free with free parameter
        lecturer = Lecturer('Selasi Agbemenu',4564541,'Mr')
        course = Course('Linear Electronics','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)
        
        print('---------------------------After Adding Lecture to Occupied---------')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        self.assertFalse(self.timetable.add_lecture(lecture,ttslot))
        print(self.timetable)
        


        #test for adding a lecture to slot that is not in the timetable 
        print('---------------------------After Adding Lecture to Occupied---------')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('6:00', '7:00'))
        self.assertFalse(self.timetable.add_lecture(lecture,ttslot))
        print(self.timetable)
Пример #14
0
    def test_occupied_slots(self):
        #if all slots are empty return an empty lists
        self.assertEqual([],self.timetable.occupied_slots())
        print(self.timetable.occupied_slots())

        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)
        
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        ttslot1 =TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('11:00', '12:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot1))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot2))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot3))

        self.assertEqual([ttslot,ttslot1,ttslot2,ttslot3],self.timetable.occupied_slots())
Пример #15
0
    def test_remove_all(self):
         #test for the case of adding a lecture to a slot that is free with free parameter
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)
        
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        ttslot1 =TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('11:00', '12:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot1))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot2))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot3))
        print('---------------------------After Adding Lectures-----------------')
        print(self.timetable)
        self.assertTrue(self.timetable.remove_all())
        print('---------------------------After Removing Lectures-----------------')
        print(self.timetable)
Пример #16
0
 def test_remove_slot(self):
     print(
         '##################################### TEST_REMOVE_SLOT##############################'
     )
     self.timetable.remove_slot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('8:00', '9:00'))
     self.timetable.remove_slot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('9:00', '10:00'))
     self.timetable.remove_slot('Wednesday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('8:00', '9:00'))
     self.timetable.remove_slot('Thursday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('8:00', '9:00'))
     print(self.timetable)
     print(
         '################################# INSERT SLOT #####################################'
     )
     self.timetable.insert_slot(
         'Monday',
         TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                       TimeSlot('8:00', '10:00')))
     print(self.timetable)
Пример #17
0
    def test_left_neighbour(self):
        #test for edge cases

        #test extreme right slot with left neighbour
        ttslot1 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('16:00', '17:00'))
        ttslot2 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('15:00', '16:00'))
        self.assertEqual(self.timetable.left_neighbour(ttslot1),ttslot2)

        #test a normal midlle slot with a left neighour
        ttslot1 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('10:00', '11:00'))
        ttslot2 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('9:00', '10:00'))
        self.assertEqual(self.timetable.left_neighbour(ttslot1),ttslot2)

        #test an extreme left slot with no left neighbour
        ttslot1 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('8:00', '9:00'))
        self.assertEqual(self.timetable.left_neighbour(ttslot1),None)

        #test for slot not in timetable
        ttslot1 =   TimetableSlot('Tues', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('16:00', '17:00'))
        self.assertEqual(self.timetable.left_neighbour(ttslot1),None)
Пример #18
0
    def test_right_neighbour(self):
         #test for extreme cases

         #test for leftmost slot with right neighbour
        ttslot1 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('8:00', '9:00'))
        ttslot2 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('9:00', '10:00'))
        self.assertEqual(self.timetable.right_neighbour(ttslot1),ttslot2)

         #test for normal middle slot with right neighbour
        ttslot1 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('10:00', '11:00'))
        ttslot2 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('11:00', '12:00'))
        self.assertEqual(self.timetable.right_neighbour(ttslot1),ttslot2)

         #test for rightmost with no right neigbour
        ttslot1 =   TimetableSlot('Mon', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('16:00', '17:00'))
        self.assertEqual(self.timetable.right_neighbour(ttslot1),None)

        #test for slot not in timtetable
        ttslot1 =   TimetableSlot('Wed', Classroom('PB001', 100, 'Petroleum building'),TimeSlot('16:00', '17:00'))
        self.assertEqual(self.timetable.right_neighbour(ttslot1),None)
Пример #19
0
 def test_timetableslot(self):
     ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                            TimeSlot('8:00', '9:00'))
     self.assertEqual(
         self.timetable.timetableslot(ttslot.day, ttslot.room,
                                      ttslot.time_slot), ttslot)
Пример #20
0
    def test_move_lecture(self):
         #test for moving lecture from a slot that is occupied

        #first create a new lecture and then add it to a slot
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        print(self.timetable)
        print('---------------------------After Adding Lecture-----------------')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        print(self.timetable)

         #test for moving lecture from a slot that is not occupied

        self.assertFalse(self.timetable.move_lecture(TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00')),
        TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('14:00', '15:00'))))
        print('---------------------After attempting wrong move-------------------')
        print(self.timetable)

         #test for moving lecture to a slot that is not occupied
        self.assertTrue(self.timetable.move_lecture(TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00')),
        TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ))
        print('------------------------------After moving lecture (unoccupied)-------------------------')
        print(self.timetable)
         #test for moving lecture to a slot that is occupied with free as True
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00', '10:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        self.assertFalse(self.timetable.move_lecture(TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00')),
        TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ))
        print(self.timetable)

        #test for moving lecture to a slot that is not occupied with free as False


        #test for moving a lecture back to itself



        #test for moving from a slot that does not exits 
        self.assertFalse(self.timetable.move_lecture(TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '10:00')),
        TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ))

        #test for moving to a slot that does not exits 
        self.assertFalse(self.timetable.move_lecture(TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00')),
        TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '12:00'))
        ))
 def setUp(self) -> None:
     self.ttslot1 = TimetableSlot('mon', Classroom('PB001', 120),
                                  TimeSlot('8:00', '9:00'))
     self.ttslot2 = TimetableSlot('mon', Classroom('PB001', 120),
                                  TimeSlot('9:00', '10:00'))
Пример #22
0
    def test_move_lecture(self):
        print(
            '############################################## Testing Move Lecture ######################'
        )
        print(
            '##########################################################################################'
        )
        print(
            '##########################################################################################'
        )
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('9:00', '10:00'))
        ttslot5 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('16:00', '17:00'))
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print(
            '############################ Before Moving lecture to another slot ##########################'
        )
        print(self.timetable)
        #moving lecture to another slot (existing and free) on the same day
        print(
            '############################ Moving lecture to another slot on same day##########################'
        )
        self.timetable.move_lecture(ttslot.day, ttslot, ttslot4.day, ttslot4)
        print(self.timetable)

        # move lecture to another (non existant) slot on the same day
        print(
            '############### Move Lecture to another slot (non existant) on the same day ###############'
        )
        self.assertFalse(
            print(
                self.timetable.move_lecture(ttslot.day, ttslot, ttslot5.day,
                                            ttslot5)))
        print(self.timetable)

        # move lecture to another slot (existing and free) on a different day
        print(
            '################## move lecture to another slot (existing and free) on a different day ##########'
        )
        #self.assertTrue(self.timetable.move_lecture(ttslot.day,ttslot,'Friday',TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))))
        print(self.timetable)

        # move lecture to another slot (non existant ) on a different day
        print(
            '################## move lecture to another slot (non existant ) on a different day on a different day ##########'
        )
        self.assertFalse(
            self.timetable.move_lecture(
                ttslot.day, ttslot, 'Monday',
                TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                              TimeSlot('18:00', '19:00'))))
        print(self.timetable)

        # move lecture to the same slot on the same day
        print(
            '################## move lecture to the same slot on the same day ##########'
        )
        self.assertFalse(
            self.timetable.move_lecture(ttslot.day, ttslot, ttslot.day,
                                        ttslot))
        print(self.timetable)

        # Move lecture to the same slot (existing and free) on a different day
        print(
            '################## Move lecture to the same slot (existing and free) on a different dayy ##########'
        )
        #self.assertTrue(self.timetable.move_lecture(ttslot.day,ttslot,'Friday',TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))))
        print(self.timetable)

        # move lecture to another slot (existing and occupied) on the same day

        # move lecture to another slot (existing and occpied) on the on a different day

        pass