Ejemplo n.º 1
0
 def ui_add(self):
     choice = input(
         "Enter the type you want to add (client/book/rental):").strip()
     if choice == 'client':
         id = input("Enter the id of the client:")
         name = input("Enter the name of the client:")
         client = Clients(id, name)
         self._service_clients.add(client)
     elif choice == 'book':
         id = input("Enter the id of the book:")
         title = input("Enter the title of the book:")
         author = input("Enter the author of the book:")
         book = Books(id, title, author)
         self._service_books.add(book)
     elif choice == 'rental':
         id = input('Enter the id of the rental:')
         book_id = input('Enter the id of the book you want to rent:')
         client_id = input(
             'Enter the id of the client that will rent the book:')
         rented_date_year = input('Enter the year of the rental:')
         rented_date_month = input("Enter the month of the rental(1-12):")
         rented_date_day = input("Enter the day of the rental(1-31):")
         rented_date = datetime.datetime(int(rented_date_year),
                                         int(rented_date_month),
                                         int(rented_date_day))
         returned_date_year = input('Enter the year of the returning::')
         returned_date_month = input(
             "Enter the month of the returning(1-12):")
         returned_date_day = input("Enter the day of the returning(1-31):")
         returned_date = datetime.datetime(int(returned_date_year),
                                           int(returned_date_month),
                                           int(returned_date_day))
         rental = Rentals(id, book_id, client_id, rented_date,
                          returned_date)
         if self.client_existence_by_id(client_id) is False:
             raise ValueError('Not existing client!')
         if self.book_existence_by_id(book_id) is False:
             raise ValueError('Not existing book!')
         self._service_rentals.add(rental)
     else:
         raise ValueError('Invalid input!')
Ejemplo n.º 2
0
 def test__str__GoodInput__PrintsFine(self):
     test= Books('1', 'The book', 'The author')
     self.assertTrue(test.__str__, '1-> "The book" by The author')
Ejemplo n.º 3
0
 def test_set_title_GoodInput_ChangesTitle(self):
     test=Books('1', 'The book', 'the author')
     test.set_title('bau')
     self.assertEqual(test.title, 'bau')
Ejemplo n.º 4
0
 def test_set_author__GoodInput__ChangesAuthor(self):
     test=Books('1', 'the book', 'the author')
     test.set_author('author')
     self.assertEqual(test.author, 'author')
Ejemplo n.º 5
0
 def test_author__GoodInput__ReturnsValue(self):
     test=Books('1','The book', 'the author')
     self.assertEqual(test.author, 'the author')