Esempio n. 1
0
 def setUp(self):
     self.__repo = Repository(StudentValidator())
     s1 = Student(1, "s1")
     s2 = Student(2, "s2")
     s3 = Student(3, "s3")
     self.__repo.add_item(s1)
     self.__repo.add_item(s2)
     self.__repo.add_item(s3)
Esempio n. 2
0
 def setUp(self):
     self.__repo = Repository(StudentValidator())
     s1 = Student(1, "s1")
     s2 = Student(2, "s2")
     s3 = Student(3, "s3")
     self.__repo.save(s1)
     self.__repo.save(s2)
     self.__repo.save(s3)
     self.__ctrl = StudentController(self.__repo)
    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)
Esempio n. 4
0
 def test_validate(self):        
     sv = StudentValidator()
     s = Student(1, "s1")
     try:
         sv.validate(s)
         assert(True)
     except ValidatorError:
         assert(False)
     
     s = Student(1, "")
     try:
         sv.validate(s)
         assert(False)
     except ValidatorError:
         assert(True)
Esempio n. 5
0
 def __load_students(self):
     try:
         with open(self.__file_name) as f:
             for line in f:
                 try:
                     arr = line.split(",")
                     p = Student(int(arr[0]), arr[1])
                     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)
    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)
Esempio n. 7
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 test_create(self):
     s1 = Student(1, "S1")
     assert ( s1.get_student_id() == 1 )
     assert ( s1.get_student_name() == "S1" )
     assert ( s1.Id == 1)
     assert ( s1.name == "S1")
Esempio n. 10
0
 def test_save(self):
     s = Student(4, "s4")
     self.__repo.add_item(s)
     assert(self.__repo.size() == 4)
 def add_student(self, Id, name):
     s = Student(Id, name)
     try:
         self.__repository.add_item(s)
     except ValidatorError as ve:
         raise StoreError(ex=ve)
Esempio n. 12
0
 def test_create(self):
     s1 = Student(1, "S1")
     assert (s1.get_student_id() == 1)
     assert (s1.get_student_name() == "S1")
     assert (s1.Id == 1)
     assert (s1.name == "S1")