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

        student_repo = Repository()
        assignment_repo = Repository()
        grade_repo = Repository()
        student_validator = Student_Validator()
        assignment_validator = Assignment_Validator()
        grade_validator = Grade_Validator()
        self._undo_service = UndoService()

        student_service = studentService(student_repo, grade_repo, student_validator, self._undo_service )
        assignment_service = assignmentService(assignment_repo, grade_repo, assignment_validator, self._undo_service)
        grade_service = gradeService(student_repo, assignment_repo, grade_repo, student_validator, assignment_validator,grade_validator, self._undo_service)

        student_validator = Student_Validator()
        assignment_validator = Assignment_Validator()
        grade_validator = Grade_Validator()

        self._student_list = student_service
        self._assignment_list = assignment_service
        self._grade_list = grade_service
        self.list_s.add_student('124', 'Mark Park', '912')
        self.list_s.add_student('125', 'Mark Park', '912')
        self.list_s.add_student('126', 'Mark Park', '912')
        self.list_s.add_student('127', 'Mark Park', '913')
        self.list_s.add_student('128', 'Mark Park', '914')
        self.assing_list.add_assignment('124', 'Homework due Tomorrow', '2021-12-22')
        self.assing_list.add_assignment('125', 'Homework due Tomorrow', '2021-12-22')
        self.assing_list.add_assignment('126', 'Homework due Tomorrow', '2021-12-22')
        self.assing_list.list_of_assignments.add_object(Assignment('127', 'Homework due Tomorrow', '2020-10-22'))
Пример #2
0
 def setUp(self):
     student_repo = Repository()
     grade_repo = Repository()
     student_validator = Student_Validator()
     undo_service = UndoService()
     student_service = studentService(student_repo, grade_repo, student_validator,undo_service)
     self._student_list = student_service
     self._student_list_repo = student_repo
Пример #3
0
    def test_addstudentservice(self):
        stud = Student('123','Mark Park','912')
        self.list_s.add_student('123','Mark Park','912')
        try:
            val = Student_Validator()
            val.validate(self.list_s,Student('123','MarkP','112'))
            self.assertFalse('not ok')
        except studentValidatorException as ve:
            s = str(ve)
            self.assertTrue('ok')
        self.assertEqual(len(self.list_s), 1)
        self.assertEqual(len(self.list_s.student_list_service), 1)
        try:
            self.list_s.add_student('123', 'Mark Park', '912')
            self.assertFalse('Not good')
        except studentException:
            self.assertTrue('OK')
        self.list_s.add_student('124', 'Mark Park', '912')
        self.list_s.add_student('125', 'Mark Park', '912')
        self.list_s.add_student('126', 'Mark Park', '912')

        self.assertEqual(len(self.list_s.student_list_service), 4)

        try:
            self.list_s.add_student('12a', 'Mark Park','123')
            self.assertFalse('Not good')
        except studentException:
            self.assertTrue('OK')

        try:
            self.list_s.add_student('392', 'Mark Park','123')
            self.assertFalse('Not good')
        except studentException:
            self.assertTrue('OK')

        try:
            self.list_s.add_student('392', 'Mark P@rk','912')
            self.assertFalse('Not good')
        except studentException:
            self.assertTrue('OK')
Пример #4
0
    def setUp(self):
        student_repo = Repository()
        assignment_repo = Repository()
        grade_repo = Repository()
        student_validator = Student_Validator()
        assignment_validator = Assignment_Validator()
        grade_validator = Grade_Validator()
        undo_service = UndoService()
        self._undo_service = undo_service
        student_service = studentService(student_repo, grade_repo, student_validator, self._undo_service )
        assignment_service = assignmentService(assignment_repo, grade_repo, assignment_validator, self._undo_service)
        grade_service = gradeService(student_repo, assignment_repo, grade_repo, student_validator, assignment_validator,grade_validator, self._undo_service)

        self._grades_list = grade_service
        self._assignments = assignment_service
        self._student_list = student_service
Пример #5
0
    def test_remove_assignment_service(self):
        self.assing_list.add_assignment('124', 'Homework due Tomorrow',
                                        '2021-12-22')
        self.assing_list.add_assignment('125', 'Homework due Tomorrow',
                                        '2021-12-22')
        self.assing_list.add_assignment('126', 'Homework due Tomorrow',
                                        '2021-12-22')
        self.assing_list.add_assignment('127', 'Homework due Tomorrow',
                                        '2021-12-22')

        student_repo = Repository()
        assignment_repo = Repository()
        grade_repo = Repository()

        student_validator = Student_Validator()
        assignment_validator = Assignment_Validator()
        grade_validator = Grade_Validator()
        g_list = gradeService(student_repo, assignment_repo, grade_repo,
                              student_validator, assignment_validator,
                              grade_validator, self._undo_service)
        self.assing_list.remove_assignment('124')

        self.assertEqual(len(self.assing_list.list_of_assignments), 3)

        try:
            self.assing_list.remove_assignment('124')
            self.assertFalse('Not good')
        except AssignmentException:
            self.assertTrue('OK')

        try:
            self.assing_list.remove_assignment('124a')
            self.assertFalse('Not good')
        except AssignmentException:
            self.assertTrue('OK')

        try:
            self.assing_list.remove_assignment('125')
            self.assertTrue('OK')
        except AssignmentException:
            self.assertFalse('Not good')
        self.assertEqual(len(self.assing_list.list_of_assignments), 2)
Пример #6
0
    def test_remove_student_service(self):
        stud = Student('123', 'Mark Park', '912')
        student_repo = Repository()
        assignment_repo = Repository()
        grade_repo = Repository()

        student_validator = Student_Validator()
        assignment_validator = Assignment_Validator()
        grade_validator = Grade_Validator()
        undo_service = UndoService()
        g_list = gradeService(student_repo, assignment_repo, grade_repo,
                              student_validator, assignment_validator,
                              grade_validator, undo_service)
        self.list_s.add_student('234', 'Mark Park', '912')
        self.list_s.add_student('235', 'Mark Park', '912')
        self.list_s.add_student('236', 'Mark Park', '912')
        self.list_s.remove_student('234')

        self.assertEqual(len(self.list_s.student_list_service), 2)

        try:
            self.list_s.remove_student('234')
            self.assertFalse('Not good')
        except studentException:
            self.assertTrue('OK')

        try:
            self.list_s.remove_student('za2')
            self.assertFalse('Not good')
        except studentException:
            self.assertTrue('OK')

        try:
            self.list_s.remove_student('392')
            self.assertFalse('Not good')
        except studentException:
            self.assertTrue('OK')
        self.assertEqual(len(self.list_s.student_list_service), 2)
Пример #7
0
            student_repo = JSONFileRepo(repoSetUp.get_studentfile)
            assignment_repo = JSONFileRepo(repoSetUp.get_assignmentfile)
            grade_repo = JSONFileRepo(repoSetUp.get_gradesfile)
        elif repoSetUp.get_mode == "database":
            student_repo = DataBaseRepo("student")
            assignment_repo = DataBaseRepo("assignment")
            grade_repo = DataBaseRepo("grade")
        else:
            raise RepositoryException(
                "Fatal Warning!... No repository initialized!\n")
    except RepositoryException as ve:
        print(str(ve))
        exit(0)

    # we now initialize the validators and so on
    student_validator = Student_Validator()
    assignment_validator = Assignment_Validator()
    grade_validator = Grade_Validator()

    undo_service = UndoService()

    student_service = studentService(student_repo, grade_repo,
                                     student_validator, undo_service)
    assignment_service = assignmentService(assignment_repo, grade_repo,
                                           assignment_validator, undo_service)
    grade_service = gradeService(student_repo, assignment_repo, grade_repo,
                                 student_validator, assignment_validator,
                                 grade_validator, undo_service)

    # we add random data if we use the inmemory storing method
    if repoSetUp.get_mode == "inmemory":