def testStudentRepo_statistics_students_best_situation(self):
        self._students = StudentRepo()
        self._disciplines = DisciplineRepo()
        self._grades = GradeRepo()

        self.__superService = SuperService(self._students, self._disciplines,
                                           self._grades)

        self._students.add_student(56, "Hill Nina")
        self._students.add_student(90, "Hol Guara")
        self._students.add_student(120, "Alex Cerg")

        self._disciplines.add_discipline(87, "Maths")
        self._disciplines.add_discipline(234, "Logic")
        self._disciplines.add_discipline(99, "Art")

        self._grades.add_grade(87, 56, 10)  #2
        self._grades.add_grade(87, 56, 3)
        self._grades.add_grade(99, 120, 4)  #1
        self._grades.add_grade(234, 120, 10)

        result = []
        result = self.__superService.students_best_situation()
        result2 = []
        result2.append(Student(120, "Alex Cerg"))
        result2.append(Student(56, "Hill Nina"))

        self.assertEqual(result[0].studentId, result2[0].studentId)
        self.assertEqual(result[0].studentName, result2[0].studentName)

        self.assertEqual(result[1].studentId, result2[1].studentId)
        self.assertEqual(result[1].studentName, result2[1].studentName)
    def testDisciplineRepo_disciplines_with_grades(self):
        self._students = StudentRepo()
        self._disciplines = DisciplineRepo()
        self._grades = GradeRepo()

        self.__superService = SuperService(self._students, self._disciplines,
                                           self._grades)

        self._students.add_student(56, "Hill Nina")
        self._students.add_student(90, "Hol Guara")
        self._students.add_student(120, "Alex Cerg")

        self._disciplines.add_discipline(87, "Maths")
        self._disciplines.add_discipline(234, "Logic")
        self._disciplines.add_discipline(99, "Art")
        self._disciplines.add_discipline(178, "Chemestry")

        self._grades.add_grade(87, 56, 10)
        self._grades.add_grade(87, 56, 3)
        self._grades.add_grade(99, 120, 4)
        self._grades.add_grade(234, 120, 10)

        result = []
        result = self.__superService.disciplines_with_grades()
        result2 = []
        result2.append(Discipline(234, "Logic"))
        result2.append(Discipline(87, "Maths"))
        result2.append(Discipline(99, "Art"))

        self.assertEqual(result[0].disciplineId, result2[0].disciplineId)
        self.assertEqual(result[0].disciplineName, result2[0].disciplineName)

        self.assertEqual(result[1].disciplineId, result2[1].disciplineId)
        self.assertEqual(result[1].disciplineName, result2[1].disciplineName)
 def testStudentRepo_addStudent(self):
     self._students = StudentRepo()
     self._students.add_student(56, "Hill Nina")
     stud = self._students.getStudentById(56)
     stud2 = Student(56, "Hill Nina")
     self.assertEqual(stud.studentId, stud2.studentId)
     self.assertEqual(stud.studentName, stud2.studentName)
 def testStudentRepo_updateStudent(self):
     self._students = StudentRepo()
     self._students.add_student(23, "Kinder Sah")
     self._students.update_student(23, "Joy")
     stud = Student(23, "Joy")
     stud2 = self._students.getStudentById(23)
     self.assertEqual(stud.studentId, stud2.studentId)
     self.assertEqual(stud.studentName, stud2.studentName)
Esempio n. 5
0
    def testGradeRepo_addGrade(self):
        self._students = StudentRepo()
        self._disciplines = DisciplineRepo()
        self._grades = GradeRepo()
        self._students.add_student(56, "Hill Nina")
        self._students.add_student(30, "Christina Shepherd")
        self._disciplines.add_discipline(78, "Maths")
        self._disciplines.add_discipline(120, "Physics")

        self._grades.add_grade(78, 30, 7)
        self.assertEqual(len(self._grades.getAll()), 1)

        self._grades.add_grade(120, 56, 10)
        self.assertEqual(len(self._grades.getAll()), 2)
Esempio n. 6
0
class TestsSecondFunctionality(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)

    def testGradeRepo_addGrade(self):
        self._students = StudentRepo()
        self._disciplines = DisciplineRepo()
        self._grades = GradeRepo()
        self._students.add_student(56, "Hill Nina")
        self._students.add_student(30, "Christina Shepherd")
        self._disciplines.add_discipline(78, "Maths")
        self._disciplines.add_discipline(120, "Physics")

        self._grades.add_grade(78, 30, 7)
        self.assertEqual(len(self._grades.getAll()), 1)

        self._grades.add_grade(120, 56, 10)
        self.assertEqual(len(self._grades.getAll()), 2)
    def testStudentRepo_search_student_id(self):
        self.studentRepo = StudentRepo()
        self._students = StudentService(self.studentRepo)
        self._students.add_student(56, "Hill Nina")
        self._students.add_student(90, "Hol Guara")
        self._students.add_student(120, "Alex Cerg")

        matches = []
        matches = self._students.search_student_id(56)
        matches2 = []
        matches2.append(Student(56, "Hill Nina"))

        self.assertEqual(matches[0].studentId, matches2[0].studentId)
        self.assertEqual(matches[0].studentName, matches2[0].studentName)
class TestsForthFunctionality(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)

    def testStudentRepo_statistics_students_failing(self):
        self._students = StudentRepo()
        self._disciplines = DisciplineRepo()
        self._grades = GradeRepo()

        self.__superService = SuperService(self._students, self._disciplines,
                                           self._grades)

        self._students.add_student(56, "Hill Nina")
        self._students.add_student(90, "Hol Guara")
        self._students.add_student(120, "Alex Cerg")

        self._disciplines.add_discipline(87, "Maths")
        self._disciplines.add_discipline(234, "Logic")
        self._disciplines.add_discipline(99, "Art")

        self._grades.add_grade(87, 56, 10)
        self._grades.add_grade(87, 56, 3)
        self._grades.add_grade(99, 120,
                               4)  #student 120 should be in the result
        self._grades.add_grade(234, 120, 10)

        result = []
        result = self.__superService.students_failing()
        result2 = []
        result2.append(Student(120, "Alex Cerg"))

        self.assertEqual(result[0].studentId, result2[0].studentId)
        self.assertEqual(result[0].studentName, result2[0].studentName)

    def testStudentRepo_statistics_students_best_situation(self):
        self._students = StudentRepo()
        self._disciplines = DisciplineRepo()
        self._grades = GradeRepo()

        self.__superService = SuperService(self._students, self._disciplines,
                                           self._grades)

        self._students.add_student(56, "Hill Nina")
        self._students.add_student(90, "Hol Guara")
        self._students.add_student(120, "Alex Cerg")

        self._disciplines.add_discipline(87, "Maths")
        self._disciplines.add_discipline(234, "Logic")
        self._disciplines.add_discipline(99, "Art")

        self._grades.add_grade(87, 56, 10)  #2
        self._grades.add_grade(87, 56, 3)
        self._grades.add_grade(99, 120, 4)  #1
        self._grades.add_grade(234, 120, 10)

        result = []
        result = self.__superService.students_best_situation()
        result2 = []
        result2.append(Student(120, "Alex Cerg"))
        result2.append(Student(56, "Hill Nina"))

        self.assertEqual(result[0].studentId, result2[0].studentId)
        self.assertEqual(result[0].studentName, result2[0].studentName)

        self.assertEqual(result[1].studentId, result2[1].studentId)
        self.assertEqual(result[1].studentName, result2[1].studentName)

    def testDisciplineRepo_disciplines_with_grades(self):
        self._students = StudentRepo()
        self._disciplines = DisciplineRepo()
        self._grades = GradeRepo()

        self.__superService = SuperService(self._students, self._disciplines,
                                           self._grades)

        self._students.add_student(56, "Hill Nina")
        self._students.add_student(90, "Hol Guara")
        self._students.add_student(120, "Alex Cerg")

        self._disciplines.add_discipline(87, "Maths")
        self._disciplines.add_discipline(234, "Logic")
        self._disciplines.add_discipline(99, "Art")
        self._disciplines.add_discipline(178, "Chemestry")

        self._grades.add_grade(87, 56, 10)
        self._grades.add_grade(87, 56, 3)
        self._grades.add_grade(99, 120, 4)
        self._grades.add_grade(234, 120, 10)

        result = []
        result = self.__superService.disciplines_with_grades()
        result2 = []
        result2.append(Discipline(234, "Logic"))
        result2.append(Discipline(87, "Maths"))
        result2.append(Discipline(99, "Art"))

        self.assertEqual(result[0].disciplineId, result2[0].disciplineId)
        self.assertEqual(result[0].disciplineName, result2[0].disciplineName)

        self.assertEqual(result[1].disciplineId, result2[1].disciplineId)
        self.assertEqual(result[1].disciplineName, result2[1].disciplineName)
Esempio n. 9
0
from UI import UI


undoController = UndoController()

# loading settings.properties

filepath = "settingstext.properties"

try:
    f = open(filepath, "r")
    line = f.readline().strip() #reading line 1 repository = ...

    line = line.split(" ")
    if line[2] == "inmemory":  #using in-memory repositories
        studentRepo = StudentRepo()
        disciplineRepo = DisciplineRepo()
        gradeRepo = GradeRepo(studentRepo, disciplineRepo)

        studentRepo.init_students()
        disciplineRepo.init_disciplines()
        gradeRepo.init_grades()

    elif line[2] == "text":
        from StudentTextRepo import StudentTextRepository
        from DisciplineTextRepo import DisciplineTextRepository
        from GradeTextRepo import GradeTextRepository

        line = f.readline().strip() #reading line 2 students = ...
        line = line.split(" ")
        studentRepo = StudentTextRepository(line[2])
class TestsFirstFunctionality(unittest.TestCase):

    
    def testStudent_CreateStudent(self):
        stud_id = 56
        stud_name = "Will Smith"
        stud = Student(stud_id, stud_name)
        self.assertEqual(stud.studentId, 56)
        self.assertEqual(stud.studentName, "Will Smith")
    
    def testStudentRepo_addStudent(self):
        self._students = StudentRepo()
        self._students.add_student(56, "Hill Nina")
        stud = self._students.getStudentById(56)
        stud2 = Student(56, "Hill Nina")
        self.assertEqual(stud.studentId, stud2.studentId)
        self.assertEqual(stud.studentName, stud2.studentName)
        
    def testStudentRepo_removeStudent(self):
        self._students = StudentRepo()
        self._students.add_student(23, "Kinder Sah")
        self._students.remove_student(23)
        self.assertEqual(len(self._students.getAll()), 0)
        
    def testStudentRepo_updateStudent(self):
        self._students = StudentRepo()
        self._students.add_student(23, "Kinder Sah")
        self._students.update_student(23, "Joy")
        stud = Student(23, "Joy")
        stud2 = self._students.getStudentById(23)
        self.assertEqual(stud.studentId, stud2.studentId)
        self.assertEqual(stud.studentName, stud2.studentName)

    def testDiscipline_CreateDiscipline(self):
        dis_id = 100
        dis_name = "Organic Chemestry"
        dis = Discipline(dis_id, dis_name)
        self.assertEqual(dis.disciplineId, 100)
        self.assertEqual(dis.disciplineName, "Organic Chemestry")
    
    def testDisciplineRepo_addDiscipline(self):
        self._disciplines = DisciplineRepo()
        self._disciplines.add_discipline(100, "Chemestry")
        dis = self._disciplines.getDisciplineById(100)
        dis2 = Discipline(100, "Chemestry")
        self.assertEqual(dis.disciplineId, dis2.disciplineId)
        self.assertEqual(dis.disciplineName, dis2.disciplineName)
        
    def testDisciplineRepo_removeDiscipline(self):
        self._disciplines = DisciplineRepo()
        self._disciplines.add_discipline(94, "Maths")
        self._disciplines.remove_discipline(94)
        self.assertEqual(len(self._disciplines.getAll()), 0)
        
    def testDisciplineRepo_updateDiscipline(self):
        self._disciplines = DisciplineRepo()
        self._disciplines.add_discipline(23, "Computer Science")
        self._disciplines.update_discipline(23, "Latin")
        dis = Discipline(23, "Latin")
        dis2 = self._disciplines.getDisciplineById(23)
        self.assertEqual(dis.disciplineId, dis2.disciplineId)
        self.assertEqual(dis.disciplineName, dis2.disciplineName)
 def testStudentRepo_removeStudent(self):
     self._students = StudentRepo()
     self._students.add_student(23, "Kinder Sah")
     self._students.remove_student(23)
     self.assertEqual(len(self._students.getAll()), 0)