def test_addPerson(self): repo = PersonRepository() cont = PersonsController(repo, PersonsActivitiesRepo(), UndoRedoController()) cont.addPerson(Person(1, "Razvan", 123, "Cluj")) self.assertIn(Person(1, "Razvan", 123, "Cluj"), repo.getAll())
def test_findPersonById(self): repo = PersonRepository() cont = PersonsController(repo, PersonsActivitiesRepo(), UndoRedoController()) cont.addPerson(Person(1, "Razvan", 123, "Cluj")) self.assertEqual(Person(1, "Razvan", 123, "Cluj"), cont.findPersonById(1))
def test_update(self): repo = PersonRepository() cont = PersonsController(repo, PersonsActivitiesRepo(), UndoRedoController()) cont.addPerson(Person(1, "Razvan", 123, "Cluj")) cont.addPerson(Person(2, "Razvan", 321, "Zalau")) cont.addPerson(Person(3, "Alex", 12231233, "Iasi")) cont.update(2, "Heghedus", 1212, "Deva") self.assertEqual(cont.findPersonById(2), Person(2, "Heghedus", 1212, "Deva"))
def test_findPersonsByName(self): repo = PersonRepository() cont = PersonsController(repo, PersonsActivitiesRepo(), UndoRedoController()) cont.addPerson(Person(1, "Razvan", 123, "Cluj")) cont.addPerson(Person(2, "Razvan", 321, "Zalau")) cont.addPerson(Person(3, "Alex", 12231233, "Iasi")) self.assertEqual(cont.findPersonsByName("Razvan"), [Person(1, "Razvan", 123, "Cluj"), Person(2, "Razvan", 321, "Zalau")])
def test_getPersonsList(self): repo = PersonRepository() cont = PersonsController(repo, PersonsActivitiesRepo(), UndoRedoController()) cont.addPerson(Person(1, "Razvan", 123, "Cluj")) cont.addPerson(Person(2, "Razvan", 321, "Zalau")) cont.addPerson(Person(3, "Alex", 12231233, "Iasi")) self.assertEqual(cont.getPersonsList(), repo.getAll())