def main(): #runTests() typee = console.getTheTypeOfRepository() if typee == 'in memory': moviesRepository = repository() customersRepository = repository() rentsRepository = repository() elif typee == 'in file': scriptpath = os.path.dirname(__file__) fileNameM = os.path.join(scriptpath, "movies.txt") fileNameC = os.path.join(scriptpath, "customers.txt") fileNameR = os.path.join(scriptpath, "rents.txt") moviesRepository = fileRepository(fileNameM, movie.readFromStr, movie.writeToStr) customersRepository = fileRepository(fileNameC, customer.readFromStr, customer.writeToStr) rentsRepository = fileRepository(fileNameR, rent.readFromStr, rent.writeToStr) c = console( moviesService(moviesRepository, validatorMovie()), customersService(customersRepository, validatorCustomer()), rentsService(moviesRepository, customersRepository, rentsRepository, validatorRent()), serviceReports(rentsRepository, customersRepository, moviesRepository)) c.interface()
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 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 testServiceMovie(self): testRepoMovie.testMovieRepo(self) self._repoMovie=repository() self._validator=validatorMovie() self._service=moviesService(self._repoMovie,self._validator) self._service.createMovie(2,"Divergent","Action","Amazing") self.assertEqual(self._service.getNrMovies(),1) self._service.update(2,"Inception","Love","Wonderful") self._movie=movie(2,"Inception","Love","Wonderful") self.assertEqual(self._repoMovie.find("id",self._movie.getId()),[self._movie])
def __init__(self): self.__bookId = 5 self.__title = "Fratii Karamazov" self.__author = "Dostoievski" self.__description = "pam pam" self.__clientId = 7 self.__name = "Ion Iliescu" self.__rentalId = 16 self.__rentedDate = 20 self.__dueDate = 13 self.__returnedDate = 30 self.__book = Book(self.__bookId, self.__title, self.__description, self.__author) self.__client = client(self.__clientId, self.__name) self.__rental = rental(self.__rentalId, self.__bookId, self.__clientId, self.__rentedDate, self.__dueDate, self.__returnedDate) self.__repo = repository() self.__valid = validation() self.__repo1 = repository() self.__business = business(self.__repo1, self.__valid)
def testRepositoryM(): repo = repository() mov = movie(1, "Divergent", "Action", "Wonderful") repo.store(mov) assert repo.get(1) == mov new = movie(1, "The pretty woman", "Love", "Good") repo.modify(new) assert repo.get(1) == new assert repo.sizeOfList() == 1 assert repo.find("id", 1) == [new] assert repo.find("title", "The pretty woman") == [new] assert repo.find("genre", "Love") == [new] repo.clearList() assert repo.sizeOfList() == 0 mov = movie(1, "Divergent", "Action", "Wonderful") repo.store(mov) repo.remove(1) assert repo.sizeOfList() == 0
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 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 testServiceM(): moviesRepository = repository() c = moviesService(moviesRepository, validatorMovie()) m = c.createMovie(1, "The same", "Tragedy", "English movie") assert m.getId() == 1 assert m.getTitle() == "The same" assert m.getGenre() == "Tragedy" assert m.getDescription() == "English movie" c.update(1, "Divergent", "Action", "One of the best") new = movie(1, "Divergent", "Action", "One of the best") assert c.get(1) == new c.remove(1) assert c.getNrMovies() == 0 m = c.createMovie(1, "Inception", "Action", "Awesome") c.find("id", 1) assert c.get(1) == m assert c.getNrMovies() == 1
def testServiceCustomer(self): return testRepoCustomer.testCustomer(self) self.__repoCustomer=repository() self.__validator=validatorCustomer() self._service=customersService(self.__repoCustomer,self.__validator) self._service.createCustomer(2,"John",2991010343434) self.assertEqual(self._service.getNrCustomers(),1) ''' black box testing''' try: self._service.createCustomer(2,"Laur",2991010343436) assert False except ValueError: assert True try: self._service.createCustomer(4,"Laur",2010343436) assert False except ValueError: assert True try: self._service.update(10,"Laur",2010343436222) assert False except ValueError: assert True try: self._service.remove(10,"Lindsey",2010343436333) assert False except ValueError: assert True try: self._service.removeAll() assert True except ValueError: assert False
def setUp(self): testMovie.setUp(self) self._repo = repository()
from Book.Book import Book from client.client import client from rental.rental import rental from repository.repository import repository from tests.tests import tests from business.business import business from console.console import console from validation.validation import validation bookRepo = repository() clientRepo = repository() rentalRepo = repository() valid = validation() bookList = business(bookRepo, valid) clientList = business(clientRepo, valid) rentalList = business(rentalRepo, valid) console = console(bookList, clientList, rentalList) t = tests() t.testModels() t.testRepository() #t.testBusiness() console.run()
for line in lines: setting = line.split("=") if len(setting) > 1: settings[setting[0]] = setting[1] f.close() return settings settings = readSettings() booksRepository = None clientsRepository = None rentalRepository = None if 'Normal' == settings['repository']: booksRepository = repository() clientsRepository = repository() rentalRepository = repository() if 'CSV' == settings['repository']: booksRepository = BookCSVFileRepository(settings['books']) clientsRepository = ClientCSVFileRepository(settings['clients']) rentalRepository = RentalCSVFileRepository(settings['rentals']) if 'binary' == settings['repository']: booksRepository = PickleFileRepository(settings['books']) clientsRepository = PickleFileRepository(settings['clients']) rentalRepository = PickleFileRepository(settings['rentals']) books_Controller = booksController(booksRepository)
def setUp(self): testRent.setUp(self) self._repo = repository()
def setUp(self): testCustomer.setUp(self) self._repo = repository()