示例#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_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')))
示例#3
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)
示例#4
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)
示例#5
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'))
        ))
示例#6
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))
示例#7
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)
示例#8
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)
示例#9
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'])
示例#10
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())
示例#11
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)
     

    csv.register_dialect('myDialect',
    delimiter = ',',
    skipinitialspace=True)
    lectures = []
    rooms = []
    with open('/home/kumbong/Desktop/Software Engineering/hex-backend/objects/curriculum.csv', 'r') as csvFile:
        reader = csv.DictReader(csvFile, dialect='myDialect')
        count = 0
        for row in reader:
            r = (dict(row))
            lecturer = Lecturer(r['Lecturer name'].strip(),r['Lecturer Id'].strip(),r['Lecturer Title'].strip())
            course = Course(r['Course name'].strip(),r['Department code'].strip(),r['Course code'].strip(),r['T'].strip(),r['P'].strip(),r['C'].strip(),r['Tutorial'].strip())
            section = Section(r['Section department'].strip(),r['Year'].strip(),r['Section code'].strip(),int(r['Class size'].strip()))
            c_item = CurriculumItem(section,course,lecturer)
            if count%3:
                lecture = Lecture(c_item,120)
            else:
                lecture = Lecture(c_item,60)
            lectures.append(lecture)
            count+=1
    csvFile.close()

    with open('/home/kumbong/Desktop/Software Engineering/hex-backend/objects/rooms.csv', 'r') as csvFile:
        reader = csv.DictReader(csvFile, dialect='myDialect')
        for row in reader:
            r = (dict(row))
            room = Classroom(r['Name'].strip(),int(r['Capacity'].strip()),r['Building'].strip(),r['Allowance'].strip())
            rooms.append(room)
    csvFile.close()
示例#13
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