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"
Ejemplo n.º 2
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 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 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
Ejemplo n.º 5
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
Ejemplo n.º 6
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