Пример #1
0
    def testStatisticsController(self):

        graRepo = GradeRepository()
        stuRepo = StudentRepository()
        disRepo = DisciplineRepository()

        disRepo.add(Discipline(1, "Dragons Language"))
        disRepo.add(Discipline(2, "How to draw anime"))
        disRepo.add(Discipline(3, "Japanese"))

        stuRepo.add(Student(1, "Putin"))
        stuRepo.add(Student(2, "Sheldon Cooper"))
        stuRepo.add(Student(3, "Nietzsche"))
        stuRepo.add(Student(4, "Mio Naruse"))

        graRepo.addGrade(Grade(1, 1, 9.9), stuRepo, disRepo)
        graRepo.addGrade(Grade(2, 1, 4.8), stuRepo, disRepo)
        graRepo.addGrade(Grade(3, 1, 5.7), stuRepo, disRepo)
        graRepo.addGrade(Grade(2, 2, 9.0), stuRepo, disRepo)
        graRepo.addGrade(Grade(1, 3, 6.0), stuRepo, disRepo)
        graRepo.addGrade(Grade(2, 3, 7.3), stuRepo, disRepo)
        graRepo.addGrade(Grade(3, 3, 4.2), stuRepo, disRepo)
        graRepo.addGrade(Grade(3, 3, 7.9), stuRepo, disRepo)

        ctrl = StatisticsController(stuRepo, disRepo, graRepo)

        assert ctrl.byDisciplineAlphabetically(3) == [[3, 'Nietzsche'],
                                                      [1, 'Putin']]
        assert ctrl.byDisciplineAlphabetically(2) == [[3, 'Nietzsche'],
                                                      [1, 'Putin'],
                                                      [2, 'Sheldon Cooper']]
        assert ctrl.failingStudents() == [[1, 'Putin']]
        assert ctrl.topStudents() == [[9.0, 2, 'Sheldon Cooper'],
                                      [6.8, 1, 'Putin'],
                                      [6.45, 3, 'Nietzsche']]
        assert ctrl.topDiscipline() == [[7.95, 1, 'Dragons Language'],
                                        [
                                            7.033333333333334, 2,
                                            'How to draw anime'
                                        ], [5.933333333333334, 3, 'Japanese']]
Пример #2
0
repoStudent.add(Student(23, "Light Yagami"))
repoStudent.add(Student(24, "Axl Rose"))
repoStudent.add(Student(25, "Harry Potter"))
repoStudent.add(Student(26, "Gottfried Wilhelm von Leibniz"))
repoStudent.add(Student(27, "Rene Descartes"))
repoStudent.add(Student(28, "Antoine Griezmann"))
repoStudent.add(Student(29, "Rafael Nadal"))
repoStudent.add(Student(30, "Barney Stinson"))
repoStudent.add(Student(31, "Lucy Heartfilia"))
repoStudent.add(Student(32, "Edward Elric"))
repoStudent.add(Student(33, "Erza Scarlet"))
repoStudent.add(Student(34, "Sena Kashiwazaki"))
repoStudent.add(Student(35, "Yusuke Urameshi"))
repoStudent.add(Student(36, "John von Neumann"))

repoGrade.addGrade(Grade(1, 1, 10), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(2, 12, 2.49), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(6, 33, 1.43), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(9, 2, 7.89), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(9, 34, 9.84), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(13, 5, 6.22), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(14, 28, 7.6), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(8, 14, 7.62), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(8, 30, 6.7), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(10, 27, 5.1), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(4, 10, 7.91), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(8, 29, 7.78), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(11, 22, 9.69), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(13, 5, 1.22), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(11, 6, 8.77), repoStudent, repoDiscipline)
repoGrade.addGrade(Grade(14, 11, 7.19), repoStudent, repoDiscipline)