def test_add_client_serv(): cl_val = ClientValidator() cl_repo = ClientRepository(cl_val) cl_serv = ClientService(cl_repo) cl_serv.add_cl_srv(1, "Geo", "Valcea") assert len(cl_repo.get_all_clients()) == 1 assert cl_repo.get_all_clients()[0].get_cl_name() == "Geo"
def setUp(self): self.__ID = 13 self.__client = Client(1, "Silviu", "Anton", 1990722170051) self.__movie = Movie(1, "Saw", "a movie about a psycho", "Horror") self.__date = date.today() self.__rent = Rent(self.__ID, self.__client, self.__movie, self.__date) self.__validator = RentValidator() self.__repo = RentFileRepository("testRent.txt") self.__movieRepo = FileRepository("testMovie.txt", Movie) self.__clientRepo = FileRepository("testClient.txt", Client) self.__service = RentService(self.__repo, self.__validator, self.__clientRepo, self.__movieRepo) self.__clientService = ClientService(self.__clientRepo, ClientValidator()) self.__movieService = MovieService(self.__movieRepo, MovieValidator())
def setUp(self): self.__ID = 13 self.__firstName = "Silviu" self.__lastName = "Anton" self.__CNP = 1990722170051 self.__client = Client(self.__ID, self.__firstName, self.__lastName, self.__CNP) self.__validator = ClientValidator() self.__badID = 5 self.__badFirstName = "" self.__badLastName = "" self.__badCNP = 12654 self.__badClient = Client(self.__badID, self.__badFirstName, self.__badLastName, self.__badCNP) self.__repo = FileRepository("testClient.txt", Client) self.__service = ClientService(self.__repo, self.__validator)
from repository.client_file_repo import ClientFileRepository from repository.client_repository import ClientRepository from repository.rental_repository import RentalRepository from services.car_service import CarService from services.client_service import ClientService from services.rental_service import RentalService from ui.user_interface import UI ''' The module where our application will start ''' cl_val = ClientValidator() car_val = CarValidator() rt_val = RentalValidator() #cl_rep = ClientRepository(cl_val) cl_rep_file = ClientFileRepository("clients.txt") #car_rep = CarRepository(car_val) car_rep_file = CarFileRepository("cars.txt") car_rep_file.remove_all() rt_rep = RentalRepository(rt_val) cl_serv = ClientService(cl_rep_file) car_serv = CarService(car_rep_file) rt_serv = RentalService(rt_rep, cl_rep_file, car_rep_file) ui = UI(car_serv, cl_serv, rt_serv) ui.show_ui()
''' Created on Nov 6, 2018 Modulul principal al aplicatiei @author: Silviu Anton ''' from services.client_service import ClientService from services.movie_service import MovieService from infrastructure.repository import FileRepository, RentFileRepository from domain.validators import ClientValidator, MovieValidator, RentValidator from ui.console import Console from services.rent_service import RentService from domain.entities import Client, Movie if __name__ == '__main__': clientRepository = FileRepository('clienti.txt', Client) clientService = ClientService(clientRepository, ClientValidator()) movieRepository = FileRepository('filme.txt', Movie) movieService = MovieService(movieRepository, MovieValidator()) rentRepository = RentFileRepository('inchirieri.txt') rentService = RentService(rentRepository, RentValidator(), clientRepository, movieRepository) console = Console(clientService, movieService, rentService) console.run()
def run_application(): """ The main method of the application :return: nothing """ try: undoRedoHandler = UndoHandler() dataManagerType = Settings.getDataManagerType() clientManager = None movieManager = None rentalManager = None if dataManagerType == "memory": # IN MEMORY clientManager = DataManager(ClientValidator) movieManager = DataManager(MovieValidator) rentalManager = DataManager(RentalValidator) elif dataManagerType == "pickle": # WITH PICKLE SERIALIZATION clientManager = DataManagerPickle(ClientValidator, "clients.pickle") movieManager = DataManagerPickle(MovieValidator, "movies.pickle") rentalManager = DataManagerPickle(RentalValidator, "rentals.pickle") elif dataManagerType == "text": # WITH SIMPLE TXT FILES: clientManager = DataManagerText(ClientValidator, "clients.text", Client) movieManager = DataManagerText(MovieValidator, "movies.text", Movie) rentalManager = DataManagerText(RentalValidator, "rentals.text", Rental) elif dataManagerType == "sql": # WITH SQL clientManager = DataManagerSql(ClientValidator, "moviestore", "clients", Client) movieManager = DataManagerSql(MovieValidator, "moviestore", "movies", Movie) rentalManager = DataManagerSql(RentalValidator, "moviestore", "rentals", Rental) elif dataManagerType == "json": # WITH JSON clientManager = DataManagerJson(ClientValidator, "clientsJSON", "clients", Client) movieManager = DataManagerJson(MovieValidator, "moviesJSON", "movies", Movie) rentalManager = DataManagerJson(RentalValidator, "rentalsJSON", "rentals", Rental) print("clientManager: ", type(clientManager)) print("movieManager: ", type(movieManager)) print("rentalManager: ", type(rentalManager)) clientService = ClientService(clientManager) movieService = MovieService(movieManager) rentalService = RentalService(rentalManager) console = Console(clientService, movieService, rentalService, undoRedoHandler) console.startConsole() except Exception as ex: print("Exception: ", ex) traceback.print_exc()
from services.client_service import ClientService client_service = ClientService()
def setUp(self): self.dataManager = DataManager(ClientValidator) self.clientService = ClientService(self.dataManager) for i in range(1, 10): self.clientService.addClient(Client(i, "Name" + str(i)))