Esempio n. 1
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)
class DisciplineControllerTestCase(unittest.TestCase):
    def setUp(self):
        self.__repo = Repository(DisciplineValidator())
        d1 = Discipline(1, "d1", "p1")
        d2 = Discipline(2, "d2", "p2")
        d3 = Discipline(3, "d3", "p3")
        self.__repo.add_item(d1)
        self.__repo.add_item(d2)
        self.__repo.add_item(d3)
        self.__ctrl = DisciplineController(self.__repo)
        
    def test_add_discipline(self):
        self.__ctrl.add_discipline(4, "d4", "p4")
        assert(self.__repo.size() == 4)
        
    def test_get_all(self):
        l = self.__ctrl.get_all()
        assert(len(l) == 3)
    
    def test_delete_discipline(self):
        self.__ctrl.delete_discipline(2)
        assert(self.__repo.size() == 2)
        
        self.__ctrl.delete_discipline(3)
        assert(self.__repo.size() == 1)
        
    def test_discipline_change(self):
        self.setUp()
        assert self.__repo.size() == 3
        d = self.__ctrl.discipline_change(1, "mate", "profmate")
        assert d.Discipline_name == "mate"
        assert d.Discipline_prof =="profmate"
        assert d.Id == 1
Esempio n. 3
0
class DisciplineControllerTestCase(unittest.TestCase):
    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)
        
    def test_add_discipline(self):
        self.__ctrl.add_discipline(4, "d4", "p4")
        assert(self.__repo.size() == 4)
        
    def test_get_all(self):
        l = self.__ctrl.get_all()
        assert(len(l) == 3)
    
    def test_delete_discipline(self):
        self.__ctrl.delete_discipline(2)
        assert(self.__repo.size() == 2)
        
        self.__ctrl.delete_discipline(3)
        assert(self.__repo.size() == 1)
        
    def test_discipline_change(self):
        self.setUp()
        assert self.__repo.size() == 3
        d = self.__ctrl.discipline_change(1, "mate", "profmate")
        assert d.Discipline_name == "mate"
        assert d.Discipline_prof =="profmate"
        assert d.Id == 1
    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 setUp(self):
     self.__repo = Repository(DisciplineValidator())
     d1 = Discipline(1, "d1", "p1")
     d2 = Discipline(2, "d2", "p2")
     d3 = Discipline(3, "d3", "p3")
     self.__repo.add_item(d1)
     self.__repo.add_item(d2)
     self.__repo.add_item(d3)
     self.__ctrl = DisciplineController(self.__repo)
Esempio n. 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()
Esempio n. 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()