def testGradeController(self):

        graRepo = GradeRepository()
        disRepo = DisciplineRepository()
        stuRepo = StudentRepository()
        undoCtrl = UndoController()
        ctrl = GradeController(graRepo, disRepo, stuRepo, undoCtrl)

        assert len(ctrl) == 0
        grade = Grade(1, 1, 9)

        try:
            ctrl.addGrade(grade)
            assert False
        except (DisciplineException, StudentException):
            assert True

        d = Discipline(1, "Japanese")
        s = Student(1, "Naruto")
        disRepo.add(d)
        stuRepo.add(s)

        ctrl.addGrade(grade)

        assert len(ctrl) == 1
    def testDisciplineController(self):
        disRepo = DisciplineRepository()
        graRepo = GradeRepository()
        stuRepo = StudentRepository()
        undoCtrl = UndoController()
        ctrl = DisciplineController(disRepo, graRepo, stuRepo, undoCtrl)

        d1 = Discipline(1, "Japanese")
        d2 = Discipline(1, "Anime")

        assert len(ctrl) == 0

        ctrl.addDiscipline(d1)
        assert len(ctrl) == 1
        assert ctrl.searchDisciplineID(1) == d1

        try:
            ctrl.addDiscipline(d1)
            assert False
        except DisciplineException:
            assert True

        try:
            ctrl.addDiscipline(d2)
            assert False
        except DisciplineException:
            assert True

        d2 = Discipline(2, "Manga")
        ctrl.addDiscipline(d2)
        assert len(ctrl) == 2
        assert ctrl.searchStringinNameDiscipline("ANG") == [d2]
        assert ctrl.searchStringinNameDiscipline("nes") == [d1]

        ctrl.updateDiscipline(1,"Anime")
        assert ctrl.searchStringinNameDiscipline("nim") == [d1]

        assert len(ctrl) == 2
        ctrl.removeDiscipline(1)
        assert len(ctrl) == 1
        assert ctrl.searchDisciplineID(1) == None
        assert ctrl.searchDisciplineID(2) == d2

        try:
            ctrl.removeDiscipline(1)
            assert False
        except DisciplineException:
            assert True

        ctrl.removeDiscipline(2)
        assert len(ctrl) == 0
Example #3
0
def testStudentController():
    stuRepo = StudentRepository()
    graRepo = GradeRepository()
    undoCtrl = UndoController()
    ctrl = StudentController(stuRepo, graRepo, undoCtrl)

    s1 = Student(1, "Vasilica")
    s2 = Student(1, "Gheorghidiu")

    assert len(ctrl) == 0

    ctrl.addStudent(s1)
    assert len(ctrl) == 1
    assert ctrl.findStudentByName("Vasilica") == [s1]
    assert ctrl.findStudentByName("John") == []

    try:
        ctrl.addStudent(s1)
        assert False
    except StudentException:
        assert True

    try:
        ctrl.addStudent(s2)
        assert False
    except StudentException:
        assert True

    s2 = Student(2, "Gheorghidiu")
    ctrl.addStudent(s2)
    assert len(ctrl) == 2
    assert ctrl.findStudentByName("Vasilica") == [s1]
    assert ctrl.findStudentByName("Gheorghidiu") == [s2]

    ctrl.updateStudent(2, "Johnny Bravo")

    assert len(ctrl) == 2
    ctrl.removeStudent(1)
    assert len(ctrl) == 1
    assert ctrl.findStudentByName("Johnny Bravo") == [s2]
    assert ctrl.findStudentByName("Vasilica") == []

    try:
        ctrl.removeStudent(1)
        assert False
    except StudentException:
        assert True

    ctrl.removeStudent(2)
    assert len(ctrl) == 0
Example #4
0
    def testStudentController(self):
        stuRepo = StudentRepository()
        graRepo = GradeRepository()
        undoCtrl = UndoController()
        disRepo = DisciplineRepository()
        ctrl = StudentController(stuRepo, graRepo, disRepo, undoCtrl)

        s1 = Student(1, "Putin")
        s2 = Student(1, "Boruto")

        assert len(ctrl) == 0

        ctrl.addStudent(s1)
        assert len(ctrl) == 1
        assert ctrl.searchStudentID(1) == s1

        try:
            ctrl.addStudent(s1)
            assert False
        except StudentException:
            assert True

        try:
            ctrl.addStudent(s2)
            assert False
        except StudentException:
            assert True

        s2 = Student(2, "Naruse")
        ctrl.addStudent(s2)
        assert len(ctrl) == 2
        assert ctrl.searchStringinNameStudent("TIN") == [s1]
        assert ctrl.searchStringinNameStudent("rus") == [s2]

        ctrl.updateStudent(1, "Hagi")

        assert len(ctrl) == 2
        ctrl.removeStudent(1)
        assert len(ctrl) == 1
        assert ctrl.searchStudentID(1) == None
        assert ctrl.searchStudentID(2) == s2

        try:
            ctrl.removeStudent(1)
            assert False
        except StudentException:
            assert True

        ctrl.removeStudent(2)
        assert len(ctrl) == 0
def testDisciplineController():
    disRepo = DisciplineRepository()
    graRepo = GradeRepository()
    undoCtrl = UndoController()
    ctrl = DisciplineController(disRepo, graRepo, undoCtrl)

    d1 = Discipline("maths", "Andrea")
    d2 = Discipline("maths", "Columban")

    assert len(ctrl) == 0

    ctrl.addDiscipline(d1)
    assert len(ctrl) == 1
    assert ctrl.findDisciplineByTeacher("Andrea") == [d1]

    try:
        ctrl.addDiscipline(d1)
        assert False
    except DisciplineException:
        assert True

    try:
        ctrl.addDiscipline(d2)
        assert False
    except DisciplineException:
        assert True

    d2 = Discipline("physics", "Huber")
    ctrl.addDiscipline(d2)
    assert len(ctrl) == 2
    assert ctrl.findDisciplineByTeacher("Andrea") == [d1]
    assert ctrl.findDisciplineByTeacher("Huber") == [d2]

    ctrl.updateDiscipline("physics", "Corega")

    assert len(ctrl) == 2
    ctrl.removeDiscipline("maths")
    assert len(ctrl) == 1
    assert ctrl.findDisciplineByTeacher("Corega") == [d2]
    assert ctrl.findDisciplineByTeacher("Andrea") == []

    try:
        ctrl.removeDiscipline("maths")
        assert False
    except DisciplineException:
        assert True

    ctrl.removeDiscipline("physics")
    assert len(ctrl) == 0
Example #6
0
# repoGrade.addGrade(Grade(6, 36, 1.19), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(13, 3, 5.94), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(7, 18, 8.41), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(14, 18, 3.51), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(7, 11, 5.08), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(4, 26, 7.71), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(9, 5, 2.03), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(7, 22, 7.86), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(9, 7, 3.79), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(4, 22, 5.88), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(10, 18, 9.59), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(5, 3, 1.63), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(2, 24, 4.64), repoStudent, repoDiscipline)
# repoGrade.addGrade(Grade(2, 10, 4.97), repoStudent, repoDiscipline)

ctrlUndo = UndoController()
ctrlDiscipline = DisciplineController(repoDiscipline, repoGrade, repoStudent,
                                      ctrlUndo)
ctrlStudent = StudentController(repoStudent, repoGrade, repoDiscipline,
                                ctrlUndo)
ctrlGrade = GradeController(repoGrade, repoDiscipline, repoStudent, ctrlUndo)
ctrlStatistics = StatisticsController(repoStudent, repoDiscipline, repoGrade)

ui = UI(ctrlDiscipline, ctrlStudent, ctrlGrade, ctrlStatistics, ctrlUndo)

ui.MainMenu()

if reads[0] == "textfiles":

    repoDiscipline.writeAlltoFile()
    repoStudent.writeAlltoFile()
Example #7
0
from Domain.Assignment import Assignment
from Repositories.StudentRepository import StudentRepository
from Repositories.AssignmentsRepository import AssignmentRepository
from Controller.UndoController import UndoController
from Domain.Rental import Rental
from Domain.RentalDTO import RentalDTO

repo_students = StudentRepository()
repo_students.add(Student("1", "student1","100"))
repo_students.add(Student("2", "student2","200"))
repo_students.add(Student("3", "student3","300"))

repo_assignments = AssignmentRepository()
repo_assignments.add(Assignment("1", "car1"))
repo_assignments.add(Assignment("2", "car2"))
repo_assignments.add(Assignment("3", "car3"))

repo_rentals = RentalRepository()
repo_rentals.add(RentalDTO("1", "1", 1))
repo_rentals.add(RentalDTO("2", "1", 2))
repo_rentals.add(RentalDTO("3", "1", 3))

ctrl_undo = UndoController()
ctrl_students = StudentController(ctrl_undo, repo_rentals, repo_students)
ctrl_assignments = AssignmentController(ctrl_undo, repo_rentals, repo_assignments)
ctrl_rentals = RentalController(repo_students, repo_assignments, repo_rentals)

ui = Console(ctrl_undo, ctrl_assignments, ctrl_students, ctrl_rentals)

ui.show()
Example #8
0
def testGradeController():
    graRepo = GradeRepository()
    disRepo = DisciplineRepository()
    stuRepo = StudentRepository()
    undoCtrl = UndoController()
    ctrl = GradeController(graRepo, disRepo, stuRepo, undoCtrl)

    assert len(ctrl) == 0

    try:
        ctrl.addStudentToDiscipline("maths", 1)
        assert False
    except (DisciplineException, StudentException):
        assert True

    try:
        ctrl.updateGrade("maths", 1, 0)
        assert False
    except (DisciplineException, StudentException):
        assert True

    try:
        ctrl.removeStudentFromDiscipline("maths", 1)
        assert False
    except (DisciplineException, StudentException):
        assert True

    d1 = Discipline("maths", "Andrea")
    disRepo.add(d1)
    assert disRepo.findByName("maths") == d1
    s1 = Student(1, "Harap-Alb")
    stuRepo.add(s1)
    assert stuRepo.findByID(1) == s1

    ctrl.addStudentToDiscipline("maths", 1)

    assert len(ctrl) == 1

    try:
        ctrl.addStudentToDiscipline("maths", 1)
        assert False
    except GradeException:
        assert True

    try:
        ctrl.updateGrade("maths", 8, 10)
        assert False
    except (GradeException, DisciplineException, StudentException):
        assert True

    ctrl.updateGrade("maths", 1, 10)
    assert len(ctrl) == 1

    ctrl.removeStudentFromDiscipline("maths", 1)
    assert len(ctrl) == 0

    try:
        ctrl.removeStudentFromDiscipline("maths", 1)
        assert False
    except GradeException:
        assert True