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)
示例#2
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)
示例#3
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()
示例#4
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)
示例#5
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
示例#7
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.__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)
 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)
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.__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)
示例#12
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"
class StudentDisciplineControllerTestCase(unittest.TestCase):
    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_assign_grades_student(self):
        s1d1 = self.__ctrl.assign_grades_student(1, 3, 2, 8)
        assert s1d1.get_student_discipline_id() == 1
        assert s1d1.get_discipline_id() == 2
        assert s1d1.get_student_id() == 3
        assert s1d1.get_grade() == 8

        s1d1 = self.__ctrl.assign_grades_student(3, 1, 1, 4)
        assert s1d1.get_discipline_id() == 1
        assert s1d1.get_student_id() == 1
        assert s1d1.get_grade() == 4

    def test_student_grade_change(self):
        s1d1 = self.__repo.find_by_id(1)
        s1d1 = self.__ctrl.student_grade_change(
            s1d1.get_student_discipline_id(), 10)
        assert s1d1.get_discipline_id() == 1
        assert s1d1.get_student_id() == 3
        assert s1d1.get_grade() == 10

    def test_get_students_with_disciplines_and_grades(self):
        l = self.__ctrl.get_students_with_disciplines_and_grades()
        assert len(l) == 3

    def test_students_and_grades_at_one_discipline_sorted(self):
        l = self.__ctrl.students_and_grades_at_one_discipline_sorted(2)
        assert len(l) == 2
        l = self.__ctrl.students_and_grades_at_one_discipline_sorted(1)
        assert len(l) == 1

    def test_students_and_grades_at_one_discipline_sorted_by_grade(self):
        l = self.__ctrl.students_and_grades_at_one_discipline_sorted_by_grade(
            2)
        assert len(l) == 2
        assert l[0].grade == 8
        assert l[1].grade == 3
示例#14
0
class RepositoryTestCase(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)

    def test_size(self):
        assert(self.__repo.size() == 3)
    
    def test_save(self):
        s = Student(4, "s4")
        self.__repo.add_item(s)
        assert(self.__repo.size() == 4)
        
    def test_get_all(self):
        l = self.__repo.get_all()
        assert(len(l) == 3)
        
    def test_delete(self):
        self.__repo.delete(3)
        assert self.__repo.size() == 2
class StudentDisciplineControllerTestCase(unittest.TestCase):
    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_assign_grades_student(self):
        s1d1 = self.__ctrl.assign_grades_student(1, 3, 2, 8)
        assert s1d1.get_student_discipline_id() == 1
        assert s1d1.get_discipline_id() == 2
        assert s1d1.get_student_id() == 3
        assert s1d1.get_grade() == 8

        s1d1 = self.__ctrl.assign_grades_student(3, 1, 1, 4)
        assert s1d1.get_discipline_id() == 1
        assert s1d1.get_student_id() == 1
        assert s1d1.get_grade() == 4

    def test_student_grade_change(self):
        s1d1 = self.__repo.find_by_id(1)
        s1d1 = self.__ctrl.student_grade_change(s1d1.get_student_discipline_id(), 10)
        assert s1d1.get_discipline_id() == 1
        assert s1d1.get_student_id() == 3
        assert s1d1.get_grade() == 10

    def test_get_students_with_disciplines_and_grades(self):
        l = self.__ctrl.get_students_with_disciplines_and_grades()
        assert len(l) == 3

    def test_students_and_grades_at_one_discipline_sorted(self):
        l = self.__ctrl.students_and_grades_at_one_discipline_sorted(2)
        assert len(l) == 2
        l = self.__ctrl.students_and_grades_at_one_discipline_sorted(1)
        assert len(l) == 1

    def test_students_and_grades_at_one_discipline_sorted_by_grade(self):
        l = self.__ctrl.students_and_grades_at_one_discipline_sorted_by_grade(2)
        assert len(l) == 2
        assert l[0].grade == 8
        assert l[1].grade == 3
示例#16
0
 def __init__(self, validator, file_name):
     Repository.__init__(self, validator)
     self.__file_name = file_name
     self.__load_students_disciplines()
 def __init__(self, validator, file_name):
     Repository.__init__(self, validator)
     self.__file_name = file_name
     self.__load_students_disciplines()
class RepositoryTestCase(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)

    def test_size(self):
        assert self.__repo.size() == 3

    def test_save(self):
        s = Student(4, "s4")
        self.__repo.add_item(s)
        assert self.__repo.size() == 4

    def test_get_all(self):
        l = self.__repo.get_all()
        assert len(l) == 3

    def test_delete(self):
        self.__repo.delete(3)
        assert self.__repo.size() == 2