def test_number_of_books_by_genres(self):
     Library(self.store, ["Fantasy", "Thriller"])
     self.add_books([self.books[0], self.books[1], self.books[2]], Library)
     actual_result = Library.number_of_books_by_genres()
     self.assertEqual({'Fantasy': 2, 'Thriller': 1}, actual_result)
     Library.add_book(self.books[3])
     actual_result = Library.number_of_books_by_genres()
     self.assertEqual({'Fantasy': 2, 'Thriller': 2}, actual_result)
     Library.remove_book(self.books[1])
     actual_result = Library.number_of_books_by_genres()
     self.assertEqual({'Fantasy': 1, 'Thriller': 2}, actual_result)
     Library.remove_book(self.books[0])
     actual_result = Library.number_of_books_by_genres()
     self.assertEqual({'Fantasy': 0, 'Thriller': 2}, actual_result)
     os.remove(os.path.realpath(self.store))
Exemplo n.º 2
0
 def get_data(self):
     """
         Gain access of the data about the books in the library.
     """
     self.data = Library.number_of_books_by_genres()
     self.genres = sorted(self.data.keys())
     self.count = list(self.data[genre] for genre in self. genres)