示例#1
0
 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
示例#2
0
 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]
示例#3
0
 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]
示例#4
0
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)
示例#5
0
 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()
示例#6
0
 def testAddGrade(self):
     gradeToAdd = grade(1, 1, 10)
     gradeList = gradeRepo()
     gradeList.addGrade(gradeToAdd)
     assert gradeList.list == [gradeToAdd]