def testUtils(self): bList = [] self.assertTrue(len(bList) == 0) bookRepo = Repository() bc = BookController(bookRepo, Statistics(bookRepo)) bc.populateBookRepository() self.assertTrue(0 < len(bookRepo.getAll()) < 100)
def testUpdateBook(self): bookRepo = Repository() bc = BookController(bookRepo, Statistics(bookRepo)) bc.populateBookRepository() bc.addBook(101, "Title", "Description", "Author") bc.updateBook(101, "title", "description", "author") self.assertTrue(bookRepo.getById(101).getTitle() == "title") self.assertTrue(bookRepo.getById(101).getAuthor() == "author") self.assertTrue(bookRepo.getById(101).getDescription() == "description")
clientRepo = Repository() rentalRepo = Repository() elif mode == "text": bookRepo = CSVRepository(path + "bookRepo.csv", Book) clientRepo = CSVRepository(path + "clientRepo.csv", Client) rentalRepo = CSVRepository(path + "rentalRepo.csv", Rental) elif mode == "binary": bookRepo = PickleRepository(path + "binaryBookRepo.pickle") clientRepo = PickleRepository(path + "binaryClientRepo.pickle") rentalRepo = PickleRepository(path + "binaryRentalRepo.pickle") elif mode == "custom": bookRepo = CustomRepository(Book) clientRepo = CustomRepository(Client) rentalRepo = CustomRepository(Rental) else: raise ValueError("Invalid option") validator = Validator() stats = Statistics(bookRepo) bookController = BookController(bookRepo, stats) bookController.populateBookRepository() clientController = ClientController(clientRepo, stats) clientController.populateClientRepository() rentalController = RentalController(bookRepo, clientRepo, rentalRepo, stats) #rentalController.populateRentals() ui = Ui(bookController, clientController, rentalController, validator, stats) ui.runUi()