def setUp(self):
        self.action_repository = ActionRepository()
        self.book_repository = BookRepository()
        self.client_repository = ClientRepository()
        self.rental_repository = RentalRepository()

        self.action_service = ActionService(self.action_repository, self.book_repository,
                                            self.client_repository, self.rental_repository)

        self.book_validator = BookValidator()
        self.client_validator = ClientValidator()
        self.rental_validator = RentalValidator()

        self.rental_service = RentalService(self.action_service, self.book_repository, self.client_repository,
                                            self.rental_repository, self.book_validator, self.client_validator,
                                            self.rental_validator)

        client = Client(1, "Name1")
        self.client_repository.add_client(client)
        client = Client(2, "Name2")
        self.client_repository.add_client(client)
        book = Book(1, "Title1", "Author1")
        self.book_repository.add_book(book)
        book = Book(2, "Title2", "Author2")
        self.book_repository.add_book(book)

        self.rental_service.add_rental(1, 1)

        assert (len(self.rental_repository.get_all_rentals()) == 1)
Example #2
0
class ActionRepositoryTest(unittest.TestCase):
    def setUp(self):
        self.action_repository = ActionRepository()

    def test_action_repository_get_all_actions(self):
        assert len(self.action_repository.get_all_actions()) == 0

    def tearDown(self):
        del self.action_repository
 def setUp(self):
     self.action_repository = ActionRepository()
     self.book_repository = BookRepository()
     self.client_repository = ClientRepository()
     self.rental_repository = RentalRepository()
     self.action_service = ActionService(self.action_repository, self.book_repository,
                                         self.client_repository, self.rental_repository)
     self.book_validator = BookValidator()
     self.book_service = BookService(self.action_service, self.book_repository, self.book_validator)
     self.book_service.add_book("Title", "Author")
     assert (len(self.book_repository.get_all_books()) == 1)
 def setUp(self):
     self.action_repository = ActionRepository()
     self.book_repository = BookRepository()
     self.client_repository = ClientRepository()
     self.rental_repository = RentalRepository()
     self.action_service = ActionService(self.action_repository, self.book_repository,
                                         self.client_repository, self.rental_repository)
     self.client_validator = ClientValidator()
     self.client_service = ClientService(self.action_service, self.client_repository, self.client_validator)
     self.client_service.add_client("Name")
     assert (len(self.client_repository.get_all_clients()) == 1)
 def setUp(self):
     self.book_repository = BookRepository()
     self.client_repository = ClientRepository()
     self.rental_repository = RentalRepository()
     self.action_repository = ActionRepository()
     self.action_service = ActionService(self.action_repository, self.book_repository,
                                         self.client_repository, self.rental_repository)
     self.book_validator = BookValidator()
     self.book_service = BookService(self.action_service, self.book_repository, self.book_validator)
     self.client_validator = ClientValidator()
     self.rental_validator = RentalValidator()
     self.client_service = ClientService(self.action_service, self.client_repository, self.client_validator)
     self.rental_service = RentalService(self.action_service, self.book_repository, self.client_repository,
                                         self.rental_repository, self.book_validator, self.client_validator,
                                         self.rental_validator)
Example #6
0
 def configure_repositories(self):
     if self.repository_type == "inmemory":
         self.book_repository = BookRepository()
         self.client_repository = ClientRepository()
         self.rental_repository = RentalRepository()
     elif self.repository_type == "textfiles":
         self.book_repository = BookTextRepository(self.book_repository,
                                                   Book.string_read_book,
                                                   Book.string_write_book)
         self.client_repository = ClientTextRepository(
             self.client_repository, Client.read_client,
             Client.write_client)
         self.rental_repository = RentalTextRepository(
             self.rental_repository, Rental.string_read_rental,
             Rental.string_write_rental)
     elif self.repository_type == "binaryfiles":
         self.book_repository = BookBinaryRepository(self.book_repository)
         self.client_repository = ClientBinaryRepository(
             self.client_repository)
         self.rental_repository = RentalBinaryRepository(
             self.rental_repository)
     elif self.repository_type == "jsonfiles":
         self.book_repository = BookJsonRepository(self.book_repository,
                                                   Book.json_read_book,
                                                   Book.json_write_book)
         self.client_repository = ClientJsonRepository(
             self.client_repository, Client.json_read_client,
             Client.json_write_client)
         self.rental_repository = RentalJsonRepository(
             self.rental_repository, Rental.json_read_rental,
             Rental.json_write_rental)
     elif self.repository_type == "database":
         self.book_repository = BookDatabaseRepository(
             Book.read_book_database, Book.write_book_database)
         self.client_repository = ClientDatabaseRepository(
             Client.read_client_database, Client.write_client_database)
         self.rental_repository = RentalDatabaseRepository(
             Rental.read_rental_database, Rental.write_rental_database)
     self.action_repository = ActionRepository()
Example #7
0
 def setUp(self):
     self.action_repository = ActionRepository()