def testCustomer(self): self._customer = customer(self.__id, self.__name, self.__cnp) self.assertEqual(self.__id, 1) self.assertEqual(self.__name, "Michael") self.assertEqual(self.__cnp, 2981211334567) self.assertEqual(self._customer, customer(self.__id, self.__name, self.__cnp))
def testCustomer(): c = customer(1, "Popescu", 1234567898765) assert c.getId() == 1 assert c.getName() == "Popescu" assert c.getCnp() == 1234567898765 c.setId(2) assert c.getId() == 2 c.setName("Ionescu") assert c.getName() == "Ionescu" c.setCnp(1230507098765) assert c.getCnp() == 1230507098765 c1 = customer(2, "Ionescu", 1230507098765) assert c == c1
def update(self, idC, name, cnp): ''' updates the informations of a customer ''' c = customer(idC, name, cnp) self.__validator.validate(c) self.__repository.modify(c)
def testRepositoryC(): customersRepository = repository() repo = customersRepository cust = customer(1, "Andrada", 2802020112345) repo.store(cust) assert repo.get(1) == cust new = customer(1, "Diana", 2820101334543) repo.modify(new) assert repo.get(1) == new assert repo.sizeOfList() == 1 assert repo.find("id", 1) == [new] assert repo.find("name", "Diana") == [new] assert repo.find("cnp", 2820101334543) == [new] repo.clearList() assert repo.sizeOfList() == 0 cust = customer(1, "Diana", 2820101334543) repo.store(cust) repo.remove(1) assert repo.sizeOfList() == 0
def testReports(self): testRentDTO.testRentDTO(self) repoM=repository() repoC=repository() repoR=repository() repoM.store(movie(11,"Inception","..","..")) repoC.store(customer(10,"James",1231231231231)) repoR.store(rent(10,11,10)) self._srv=serviceReports(repoR,repoC,repoM) self._newRentDTO=rentDTO(10,10,"James",11,"Inception",10) self.assertEqual(len(self._srv.createTheDTOList()),1)
def createCustomer(self, idC, name, cnp): ''' creates a customer in: ->idC:int unique ->name:string ->cnp:int out:the customer created ''' c = customer(idC, name, cnp) self.__validator.validate(c) self.__repository.store(c) return c
def testRentService(self): testRepoRent.testRent(self) self._repoRent=repository() self._repoM=repository() self._repoC=repository() self._repoM.store(movie(12,"It","Horror","Orrible")) self._repoC.store(customer(13,"Tudor",1231121231231)) self._validator=validatorRent() self._service=rentsService(self._repoM,self._repoC,self._repoRent,self._validator) self._service.createRent(10,12,13) self.assertEqual(self._service.getNrRents(),1) self._rent=rent(10,12,13) self.assertEqual(self._repoRent.find("id",self._rent.getId()),[self._rent])
def testServiceC(): customersRepository = repository() ctrl = customersService(customersRepository, validatorCustomer()) c = ctrl.createCustomer(1, "Berinde", 1672030123345) assert c.getId() == 1 assert c.getName() == "Berinde" assert c.getCnp() == 1672030123345 ctrl.update(1, "Modoi", 1672030128888) new = customer(1, "Modoi", 1672030128888) assert ctrl.get(1) == new ctrl.remove(1) assert ctrl.getNrCustomers() == 0 c = ctrl.createCustomer(1, "Istvanc", 1672030129999) ctrl.find("id", 1) assert ctrl.get(1) == c assert ctrl.getNrCustomers() == 1
def testFileRepo(self): testCustomer.testCustomer(self) self._repo=fileRepository(self._fileName,customer.readFromStr,customer.writeToStr) self._another=customer(10,"Ingrid",1010101010101) self._repo.store(self._another) self.assertEqual(self._repo.find("id",10)[0].getName(),"Ingrid")