예제 #1
0
 def update(self,id,name,phone_number,address):
     """Update a person entity from the reposity.
     Args:
         id(uint): the id of the person entity to be updated
         name(str): the new name of the person
         phone_number(str): the new phone number of the person
         address(str): the new address of the person
     Returns:
         None
     """
     self.__person_repository.update(Person(id,name,phone_number,address))
예제 #2
0
 def add(self,id,name,phone_number,address):
     """Add a new person entity to the person repository.
     Args:
         id(uint): the id of the person
         name(str): the name of the person
         phone_number(str): the phone number of the person
         address(str): the address of the person
     Returns:
         None
         """
     self.__person_repository.save(Person(id,name,phone_number,address))
예제 #3
0
 def modifyPerson(self, idPers, name, address):
     '''
     Modifies a person if it exists
     :param idPers:
     :return: returns the new Person
     '''
     try:
         newPerson = Person(idPers, name, address)
         self.__rep.updateElem(newPerson)
         return newPerson
     except ValidatorException as ex:
         print(ex.args)
예제 #4
0
 def __readFromFile(self):
     try:
         f = open(self.__fName, 'r')
         line = f.readline().strip()
         while line != "":
             args = line.split(",")
             person = Person(args[0], args[1], args[2])
             PersonRepository.add(self, person)
             line = f.readline().strip()
     except IOError:
         raise FileRepoException("sth is not ok... ")
     finally:
         f.close()
예제 #5
0
    def test_person_validator(self):
        # invalid id check
        person = Person("string", "John", "0756705316", "street 1")
        self.assertRaises(PersonValidatorException, PersonValidator.validate,
                          person)

        person = Person(1, 123, "0756705316", "street 1")

        self.assertRaises(PersonValidatorException, PersonValidator.validate,
                          person)

        person = Person(1, "John", 1234, "street 1")

        self.assertRaises(PersonValidatorException, PersonValidator.validate,
                          person)

        person = Person(1, "John", "a123456789", "street 1")
        self.assertRaises(PersonValidatorException, PersonValidator.validate,
                          person)

        person = Person(1, "John", "0756705316", 123)

        self.assertRaises(PersonValidatorException, PersonValidator.validate,
                          person)
예제 #6
0
 def createPerson(self, idPers, name, addr):
     '''
     store a person
     :param idPers: string
     :param name: string
     :param addr: string
     :return: the person
     :post: student added to the repository
     :raise: RepositoryException - if person already exists
     :raise: ValidationException - if person fields are invalid
     '''
     #create a person object
     person = Person(idPers, name, addr)
     #store person into using repository
     self.__rep.store(person)
     return person
예제 #7
0
    def test_get_all(self):
        p = Person(1, "John", "0756705316", "street 1")
        self.__repository.save(p)

        self.assertEqual(len(self.__repository.get_all()), 1,
                         "repository size should be 1")
예제 #8
0
 def ui_add_person(self):
     id = len(self._person_controller.return_all()) + 1
     immunization = "nonvaccinated"
     status = "healthy"
     p = Person(id, immunization, status)
     self._person_controller.add(p)
예제 #9
0
파일: console.py 프로젝트: TamasFlorin/UBB
    def add_person(self):
        person_id = input("person id:")

        if not Common.get_type(person_id) is int:
            raise ValueError("Person id must be an integer.")

        person_id = int(person_id)

        name = input("name:")

        phone_number = input("phone number:")

        address = input("address:")

        CallStack.add_undo_operation(UndoHandlers.ADD_PERSON_HANDLER,self.__person_controller,Person(person_id,name,phone_number,address)) 

        self.__person_controller.add(person_id,name,phone_number,address)
예제 #10
0
 def setUp(self):
     super().setUp()
     self.__person = Person(1,"Johny","0756705316","street nr1")
예제 #11
0
 def test_eq(self):
     self.assertFalse(self.__person==Person(2,"lol","0000000000","street nr 2"),"Persons should not be equal.")