def testGetStudentAverageForDiscipline(self): gradeList = gradeRepo() gradeToAdd = grade(1, 1, 10) gradeList.addGrade(gradeToAdd) gradeToAdd2 = grade(1, 1, 9) gradeList.addGrade(gradeToAdd2) assert gradeList.getStudentAverageForDiscipline(1, 1) == 9.5
def testRemoveGradesByDisciplineID(self): gradeList = gradeRepo() gradeToAdd = grade(1, 1, 10) gradeList.addGrade(gradeToAdd) gradeToAdd2 = grade(2, 2, 9) gradeList.addGrade(gradeToAdd2) gradeList.removeGradesByDisciplineID(1) assert gradeList.list == [gradeToAdd2]
def testRemoveGradesByStudentID(self): gradeList = gradeRepo() gradeToAdd = grade(1, 1, 10) gradeList.addGrade(gradeToAdd) gradeToAdd2 = grade(1, 2, 9) gradeList.addGrade(gradeToAdd2) gradeList.removeGradesByStudentID(1) assert gradeList.list == [gradeToAdd2]
def execute(): """ Executes the application, according to the command line arguments specified. """ args = parse() image = args.image # Switch on the options if args.test: unittest() elif args.grade: grade(image) else: launch(image)
def addNewGrade(self, disciplineID, studentID, gradeValue, recordForUndo=True): ''' Function that adds a new grade to the grade repository Input: disciplineID, studentID - positive int, gradeValue - float value between 1 and 10 ''' newGrade = grade (disciplineID, studentID, gradeValue) if gradeValue < 1 or gradeValue > 10: raise ValueError ("Invalid grade value") self.repo.addGrade(newGrade) if recordForUndo == True: undo = FunctionCall(self.removeGrade, False, disciplineID, studentID, gradeValue) redo = FunctionCall(self.addNewGrade, False, disciplineID, studentID, gradeValue, False) operation = Operation(undo, redo) self.undoRedoController.recordOperation(operation) self.undoRedoController.updateHistory()
def testAddGrade(self): gradeToAdd = grade(1, 1, 10) gradeList = gradeRepo() gradeList.addGrade(gradeToAdd) assert gradeList.list == [gradeToAdd]