示例#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)
     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)
class StudentControllerTestCase(unittest.TestCase):
    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)
        self.__ctrl = StudentController(self.__repo)
        
    def test_add_student(self):
        self.__ctrl.add_student(4, "s4")
        assert(self.__repo.size() == 4)
        
    def test_get_all(self):
        l = self.__ctrl.get_all()
        assert(len(l) == 3)
    
    def test_delete_student(self):
        self.__ctrl.delete_student(3)
        assert self.__repo.size() == 2
    
    def test_find_student(self):
        s = self.__ctrl.find_student(2)
        assert s.Id == 2
        assert s.name == "s2"
        
        s = self.__ctrl.find_student(1)
        assert s.Id == 1
        assert s.name == "s1"
示例#4
0
class StudentControllerTestCase(unittest.TestCase):
    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)
        self.__ctrl = StudentController(self.__repo)
        
    def test_add_student(self):
        self.__ctrl.add_student(4, "s4")
        assert(self.__repo.size() == 4)
        
    def test_get_all(self):
        l = self.__ctrl.get_all()
        assert(len(l) == 3)
    
    def test_delete_student(self):
        self.__ctrl.delete_student(3)
        assert self.__repo.size() == 2
    
    def test_find_student(self):
        s = self.__ctrl.find_student(2)
        assert s.Id == 2
        assert s.name == "s2"
        
        s = self.__ctrl.find_student(1)
        assert s.Id == 1
        assert s.name == "s1"
 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)
     self.__ctrl = StudentController(self.__repo)
示例#6
0
    def main(self):
        student_repo = Repository(StudentValidator())
        sc = StudentController(student_repo)

        discipline_repo = Repository(DisciplineValidator())
        dc = DisciplineController(discipline_repo)

        cons = Console(sc, dc)
        cons.run()
示例#7
0
    def main(self):
        
        #student_repo = Repository(StudentValidator())        
        student_repo = StudentFileRepository(StudentValidator(),"../../data/students") 
        sc = StudentController(student_repo)

        discipline_repo = DisciplineFileRepository(DisciplineValidator(), "../../data/disciplines")
        dc = DisciplineController(discipline_repo)
        
        student_discipline_repo = StudentDisciplineFileRepository(StudentDisciplineValidator(), "../../data/student_discipline")
        sdc = StudentDisciplineController(student_repo, discipline_repo, student_discipline_repo)
        
        cons = Console(sc, dc, sdc)
        cons.run()