def setUp(self):
        self.__DisciplineRepo = Repository(DisciplineValidator())
        d1 = Discipline(1, "mate", "prof mate")
        d2 = Discipline(2, "info", "prof info")
        self.__DisciplineRepo.add_item(d1)
        self.__DisciplineRepo.add_item(d2)
        self.__Dctrl = DisciplineController(self.__DisciplineRepo)

        self.__StudentRepo = Repository(StudentValidator())
        s1 = Student(3, "Ion")
        s2 = Student(2, "Maria")
        s3 = Student(1, "Ionica")
        self.__StudentRepo.add_item(s1)
        self.__StudentRepo.add_item(s2)
        self.__StudentRepo.add_item(s3)
        self.__Sctrl = StudentController(self.__StudentRepo)

        self.__repo = Repository(StudentDisciplineValidator())
        sd = Student_Discipline(1, s1.get_student_id(), d1.get_discipline_id(), 6)
        self.__repo.add_item(sd)

        sd = Student_Discipline(2, s2.get_student_id(), d2.get_discipline_id(), 8)
        self.__repo.add_item(sd)

        sd = Student_Discipline(4, s3.get_student_id(), d2.get_discipline_id(), 3)
        self.__repo.add_item(sd)
        self.__ctrl = StudentDisciplineController(self.__StudentRepo, self.__DisciplineRepo, self.__repo)
 def test_create(self):
     d1 = Discipline(1, "d1", "p1")
     assert ( d1.get_discipline_id() == 1 )
     assert ( d1.get_discipline_name() == "d1" )
     assert ( d1.get_discipline_prof() == "p1")
     assert ( d1.Id == 1)
     assert ( d1.Discipline_name == "d1")
     assert ( d1.Discipline_prof == "p1")
示例#3
0
 def test_create(self):
     d1 = Discipline(1, "d1", "p1")
     assert (d1.get_discipline_id() == 1)
     assert (d1.get_discipline_name() == "d1")
     assert (d1.get_discipline_prof() == "p1")
     assert (d1.Id == 1)
     assert (d1.Discipline_name == "d1")
     assert (d1.Discipline_prof == "p1")
示例#4
0
 def setUp(self):
     self.__repo = Repository(DisciplineValidator())
     d1 = Discipline(1, "d1", "p1")
     d2 = Discipline(2, "d2", "p2")
     d3 = Discipline(3, "d3", "p3")
     self.__repo.save(d1)
     self.__repo.save(d2)
     self.__repo.save(d3)
     self.__ctrl = DisciplineController(self.__repo)
示例#5
0
 def test_validate(self):        
     dv = DisciplineValidator()
     d = Discipline(1, "d1", "p1")
     try:
         dv.validate(d)
         assert(True)
     except ValidatorError:
         assert(False)
     
     d = Discipline(1, "", "")
     try:
         dv.validate(d)
         assert(False)
     except ValidatorError:
         assert(True)
 def discipline_change(self, Id, name, prof):
     try:
         d = Discipline(Id, name, prof)
         self.__repository.update(d)
         return d
     except ValueError as ve:
         raise StoreError(ex=ve)
    def setUp(self):
        self.__DisciplineRepo = Repository(DisciplineValidator())
        d1 = Discipline(1, "mate", "prof mate")
        d2 = Discipline(2, "info", "prof info")
        self.__DisciplineRepo.add_item(d1)
        self.__DisciplineRepo.add_item(d2)
        self.__Dctrl = DisciplineController(self.__DisciplineRepo)

        self.__StudentRepo = Repository(StudentValidator())
        s1 = Student(3, "Ion")
        s2 = Student(2, "Maria")
        s3 = Student(1, "Ionica")
        self.__StudentRepo.add_item(s1)
        self.__StudentRepo.add_item(s2)
        self.__StudentRepo.add_item(s3)
        self.__Sctrl = StudentController(self.__StudentRepo)

        self.__repo = Repository(StudentDisciplineValidator())
        sd = Student_Discipline(1, s1.get_student_id(), d1.get_discipline_id(),
                                6)
        self.__repo.add_item(sd)

        sd = Student_Discipline(2, s2.get_student_id(), d2.get_discipline_id(),
                                8)
        self.__repo.add_item(sd)

        sd = Student_Discipline(4, s3.get_student_id(), d2.get_discipline_id(),
                                3)
        self.__repo.add_item(sd)
        self.__ctrl = StudentDisciplineController(self.__StudentRepo,
                                                  self.__DisciplineRepo,
                                                  self.__repo)
示例#8
0
 def __load_disciplines(self):
     try:
         with open(self.__file_name) as f:
             for line in f:
                 try:
                     arr = line.split(",")
                     p = Discipline(int(arr[0]), arr[1], arr[2])
                     self.add_item(p)
                 except Exception as ex:
                     raise RepositoryError("Corrupted file", ex)
     except Exception as ex:
         raise RepositoryError("Error opening file " + self.__file_name, ex)
示例#9
0
 def test_validate(self):
     sv = StudentValidator()
     dv = DisciplineValidator()
     sdv = StudentDisciplineValidator()
     s = Student(1, "s1")
     d = Discipline(1, "d1", "p1")
     d1s1 = Student_Discipline(10,s.get_student_id() , d.get_discipline_id(),5)
     try:
         sv.validate(s)
         dv.validate(d)
         sdv.validate(d1s1)
         assert True
     except ValidatorError:
         assert False
     
     sv = StudentValidator()
     dv = DisciplineValidator()
     sdv = StudentDisciplineValidator()
     s = Student(1, "")
     d = Discipline(1, "", "")
     d1s1 = Student_Discipline(2, s.get_student_id() ,d.get_discipline_id(),5)
     try:
         sv.validate(s)
         dv.validate(d)
         sdv.validate(d1s1)
         assert False
     except ValidatorError:
         assert True
     
     sv = StudentValidator()
     dv = DisciplineValidator()
     sdv = StudentDisciplineValidator()
     s = Student(1, "s1")
     d = Discipline(1, "d1", "p1")
     d1s1 = Student_Discipline(3, s.get_student_id() ,d.get_discipline_id(),-5)
     try:
         sv.validate(s)
         dv.validate(d)
         sdv.validate(d1s1)
         assert False
     except ValidatorError:
         assert True
 def test_validate(self):
     sv = StudentValidator()
     dv = DisciplineValidator()
     sdv = StudentDisciplineValidator()
     s = Student(1, "s1")
     d = Discipline(1, "d1", "p1")
     d1s1 = Student_Discipline(10,s.get_student_id() , d.get_discipline_id(),5)
     try:
         sv.validate(s)
         dv.validate(d)
         sdv.validate(d1s1)
         assert True
     except ValidatorError:
         assert False
     
     sv = StudentValidator()
     dv = DisciplineValidator()
     sdv = StudentDisciplineValidator()
     s = Student(1, "")
     d = Discipline(1, "", "")
     d1s1 = Student_Discipline(2, s.get_student_id() ,d.get_discipline_id(),5)
     try:
         sv.validate(s)
         dv.validate(d)
         sdv.validate(d1s1)
         assert False
     except ValidatorError:
         assert True
     
     sv = StudentValidator()
     dv = DisciplineValidator()
     sdv = StudentDisciplineValidator()
     s = Student(1, "s1")
     d = Discipline(1, "d1", "p1")
     d1s1 = Student_Discipline(3, s.get_student_id() ,d.get_discipline_id(),-5)
     try:
         sv.validate(s)
         dv.validate(d)
         sdv.validate(d1s1)
         assert False
     except ValidatorError:
         assert True
 def add_discipline(self, Id, name, prof):
     try:
         s = Discipline(Id, name, prof)
         self.__repository.save(s)
     except ValidatorError as ve:
         raise StoreError(ex=ve)