def test_prerequisites(self): plannerIO = PlannerIO() studyPlan = plannerIO.loadStudyPlan('studyplan2.csv') studyPlan.setAvailableCourses(plannerIO.loadCourses('courses1.csv')) dissatisfied = studyPlan.listCourseNamesWithDissatisfiedPrerequisites() self.assertTrue('fysiikka 2' in dissatisfied, 'something wrong with dissatisfied prerequisites') self.assertTrue('matematiikka 3' in dissatisfied, 'something wrong with dissatisfied prerequisites')
def test_loadAndSaveStudyPlan2(self): plannerIO = PlannerIO() studyPlan = plannerIO.loadStudyPlan('outputFile.csv') year1, period1 = studyPlan.getCourse('matematiikka 2') self.assertEqual(0, year1, 'wrong year') self.assertEqual(Period(Period.III, Period.IV), period1, 'wrong period') year2, period2 = studyPlan.getCourse('puhekurssi') self.assertEqual(-1, year2, 'wrong year') self.assertEqual(None, period2, 'wrong period') year3, period3 = studyPlan.getCourse('kirjoituskurssi') self.assertEqual(-2, year3, 'wrong year') self.assertEqual(None, period3, 'wrong period')
def __init__(self, courseListFileName): super(MainWindow, self).__init__() self.courseListFileName = courseListFileName self.plannerIO = PlannerIO() self.studyPlan = None self.studyPlanner = None self.setWindowTitle("Study Planner") openFile = QtGui.QAction("Open", self) openFile.setShortcut("Ctrl+O") openFile.setStatusTip("Open a study plan") openFile.triggered.connect(self.openDialog) saveFile = QtGui.QAction("Save", self) saveFile.setShortcut("Ctrl+S") saveFile.setStatusTip("Save the study plan") saveFile.triggered.connect(self.saveDialog) menubar = self.menuBar() fileMenu = menubar.addMenu("&File") fileMenu.addAction(openFile) fileMenu.addAction(saveFile) self.show()
class MainWindow(QtGui.QMainWindow): def __init__(self, courseListFileName): super(MainWindow, self).__init__() self.courseListFileName = courseListFileName self.plannerIO = PlannerIO() self.studyPlan = None self.studyPlanner = None self.setWindowTitle("Study Planner") openFile = QtGui.QAction("Open", self) openFile.setShortcut("Ctrl+O") openFile.setStatusTip("Open a study plan") openFile.triggered.connect(self.openDialog) saveFile = QtGui.QAction("Save", self) saveFile.setShortcut("Ctrl+S") saveFile.setStatusTip("Save the study plan") saveFile.triggered.connect(self.saveDialog) menubar = self.menuBar() fileMenu = menubar.addMenu("&File") fileMenu.addAction(openFile) fileMenu.addAction(saveFile) self.show() def openDialog(self): fname = QtGui.QFileDialog.getOpenFileName(self, "Open file", "studyplan.csv") self.studyPlan = self.plannerIO.loadStudyPlan(fname) self.studyPlan.setAvailableCourses(self.plannerIO.loadCourses(self.courseListFileName)) self.studyPlanner = StudyPlanner(self.studyPlan) self.setCentralWidget(self.studyPlanner) def saveDialog(self): fname = QtGui.QFileDialog.getSaveFileName(self, "Save file", "studyplan.csv") self.plannerIO.saveStudyPlan(fname, self.studyPlan)
def test_loadCourses(self): plannerIO = PlannerIO() courses = plannerIO.loadCourses('courses1.csv') self.assertEqual(10, courses['matematiikka 1'].ects, 'wrong number of credits')