def testNoFreeDay(self): ''' Verify that query returns unsat if a freeday is indeed impossible ''' compmods = ['CS1010', 'CS1231', 'CS2105', 'ST2131'] optmods = ['MA1101R', 'CS2020'] options = {'numFreedays': 1} timetable = querySolverBV.solveQuery(5, [], optmods, options, semester = SEMESTER) self.assertTrue(len(timetable) == 0)
def testSatAndValidTimetable2(self): ''' Returns empty (unsat) during test, should not be the case ''' options = {'noLessonsAfter': 19, 'noLessonsBefore': 8} compmods = ['MA1101R', 'ACC1002', 'GER1000', 'GEQ1000'] timetable = querySolverBV.solveQuery(4, compmods, [], options, semester = SEMESTER) print timetable self.assertTrue(self.calendarUtils.scheduleValid(timetable)) self.assertTrue(self.calendarUtils.checkNoLessonsAfter(timetable, 19))
def testSatAndValidTimetable(self): ''' Returns empty (unsat) during test, should not be the case ''' optmods = ['GEQ1000', 'CS1010', 'MA1102R', 'MA1101R'] options = {} timetable = querySolverBV.solveQuery(4, [], optmods, options, semester = SEMESTER) print timetable self.assertTrue(self.calendarUtils.scheduleValid(timetable)) self.assertTrue(self.calendarUtils.checkNoLessonsAfter(timetable, 19))
def testLockedLessonSlots1(self): ''' Verify that lockedLessonSlots appear in the timetable ''' lockedLessonSlots = ['MA1101R_Tutorial_T10'] compMods = ['CS1231', 'CS1020', 'CS2100', 'CS2105', 'MA1101R'] options = {'lockedLessonSlots': lockedLessonSlots} timetable = querySolverBV.solveQuery(5, compMods, [], options, semester = SEMESTER) print timetable self.assertTrue(self.calendarUtils.scheduleValid(timetable)) self.assertTrue(lockedLessonSlots[0] in timetable)
def testNoLessonAfter(self): '''Verify that assertions represent a timetable that has no lessons before the user defined time ''' optmods = ['CS1231', 'CS1020', 'CS2100', 'CS2020', 'CS2105', 'MA1101R', 'ST2131'] options = {'noLessonsAfter': 19} timetable = querySolverBV.solveQuery(4, [], optmods, options, semester = SEMESTER) self.assertTrue(self.calendarUtils.scheduleValid(timetable)) self.assertTrue(self.calendarUtils.checkNoLessonsAfter(timetable, 19))
def testSpecificAndNonSpecificFreedays(self): ''' Verify that timetable contains the specified free day and another soft free day ''' compMods = ['CS2100', 'CS1010', 'GEQ1000', 'GER1000'] optMods = [] options = {'numFreedays': 2, 'freedays': ['Tuesday']} timetable1 = querySolverBV.solveQuery(4, compMods, [], options, semester=SEMESTER) print timetable1 # random.shuffle(compMods) # print compMods timetable2 = querySolverBV.solveQuery(4, compMods, [], options, semester=SEMESTER) print timetable2 print isScheduleSame(timetable1, timetable2)
def testLunchHours(self): numMods = 5 optMods = [] compMods = ['CS1010', 'CS1231', 'GEQ1000', 'GER1000', 'MA1101R'] options = {"lunchBreak": True} timetable = querySolverBV.solveQuery(numMods, compMods, optMods, options, semester=SEMESTER) self.checkTimetable(timetable, options)
def testFreedayQuery(self): ''' Verify that assertions represent a timetable with a freeday ''' optmods = ['CS1231', 'CS1020', 'CS2100', 'CS2020', 'CS2105', 'MA1101R', 'ST2131'] options = {'numFreedays': 1} timetable = querySolverBV.solveQuery(4, [], optmods, options, semester = SEMESTER) print timetable print self.calendarUtils.gotFreeDay(timetable) self.assertTrue(self.calendarUtils.scheduleValid(timetable)) self.assertTrue(len(self.calendarUtils.gotFreeDay(timetable)) > 0)
def testSpecificAndNonSpecificFreedays(self): ''' Verify that timetable contains the specified free day and another soft free day NOTE numFreedays is deprecated, not used in live version for now ''' compMods = ['CS2100', 'CS1010', 'GEQ1000', 'GER1000'] optMods = [] options = {'numFreedays': 2, 'freedays': ['Tuesday']} timetable = querySolverBV.solveQuery(4, compMods, [], options, semester=SEMESTER) self.checkTimetable(timetable, options)
def testSpecificFreedays(self): ''' Verify that timetable contains the specified free day ''' compMods = ['CS2105', 'CS2107', 'GEQ1000', 'GER1000', 'MA1101R'] optMods = [] options = {'numFreedays': 1, 'freedays': ['Tuesday']} timetable = querySolverBV.solveQuery(5, compMods, [], options, semester = SEMESTER) print timetable self.assertTrue(self.calendarUtils.scheduleValid(timetable)) freedays = self.calendarUtils.gotFreeDay(timetable) for d in ['Even Tuesday', 'Odd Tuesday']: self.assertTrue(d in freedays) self.assertTrue(len(self.calendarUtils.gotFreeDay(timetable)) > 0)
def testFreeday(self): ''' Return a timetable that has at least one free day ''' compMods = ['CS1231', 'CS2100', 'MA1101R', 'MA1102R'] optMods = [] numMods = 4 options = {'freeday': True} timetable = querySolverBV.solveQuery(numMods, compMods, [], options, semester=SEMESTER) self.checkTimetable(timetable, options)
def testWeekendLessons(self): ''' Edge case where the module has weekend lessons (e.g. CG1111) ''' numMods = 5 optMods = [ 'CG1111', 'EN1101E', 'GE1101E', 'LA4203', 'MA1100', 'PC1141' ] compMods = [] options = {} timetable = querySolverBV.solveQuery(numMods, compMods, optMods, options, semester=SEMESTER) self.checkTimetable(timetable, options)
def testUndefinedTimetable(self): ''' some slots are undefined ''' numMods = 4 compMods = [] optMods = [ 'GEQ1000', 'MA1101R', 'GER1000', 'MA1100', 'CS1010', 'CS1231' ] options = {'freeday': True, 'possibleFreedays': []} timetable = querySolverBV.solveQuery(numMods, compMods, optMods, options, semester=SEMESTER) self.checkTimetable(timetable, options)
def testLockedLessons(self): ''' Timetable returned should include specified locked lesson slot ''' numMods = 6 optMods = [] compMods = [ 'UTC2700', 'CS3230', 'CS2103T', 'CS2106', 'ST2132', 'CS2101' ] options = {'lockedLessonSlots': ['CS2101_Sectional Teaching_6']} timetable = querySolverBV.solveQuery(numMods, compMods, optMods, options, semester=SEMESTER) print timetable self.checkTimetable(timetable, options)
def testFreedayFromSubset(self): ''' Return a timetable that has at least one free day from specified weekdays ''' compMods = ['CS1231', 'CS2100', 'MA1101R', 'MA1102R'] optMods = [] numMods = 4 options = { 'freeday': True, 'possibleFreedays': ['Tuesday', 'Wednesday'] } timetable = querySolverBV.solveQuery(numMods, compMods, [], options, semester=SEMESTER) self.checkTimetable(timetable, options)
def testSpecificFreedayandNoLessonsBefore(self): ''' Live version returned incorrectly unsat NOTE numFreedays is deprecated, not used in live version for now ''' compMods = ['GEQ1000', 'PS2203', 'PS2237', 'PS3271', 'SN1101E'] optMods = [] options = { 'numFreedays': 2, 'freedays': ['Monday', 'Tuesday'], 'noLessonsBefore': 8 } numMods = 5 timetable = querySolverBV.solveQuery(numMods, compMods, optMods, options, semester=SEMESTER) self.checkTimetable(timetable, options)