diff --git a/exercicios/para-casa/Book.py b/exercicios/para-casa/Book.py new file mode 100644 index 0000000..edd1d41 --- /dev/null +++ b/exercicios/para-casa/Book.py @@ -0,0 +1,7 @@ +class Book: + def __init__(self, name, author, year, comentary): + self.name = name + self.author = author + self.year = year + self.comentary = comentary + self.borrowed = False \ No newline at end of file diff --git a/exercicios/para-casa/Bookstolend.py b/exercicios/para-casa/Bookstolend.py new file mode 100644 index 0000000..8b0a387 --- /dev/null +++ b/exercicios/para-casa/Bookstolend.py @@ -0,0 +1,3 @@ +class BooksToLend: + def __init__(self, name): + self.name = name \ No newline at end of file diff --git a/exercicios/para-casa/Library.py b/exercicios/para-casa/Library.py new file mode 100644 index 0000000..8083812 --- /dev/null +++ b/exercicios/para-casa/Library.py @@ -0,0 +1,30 @@ +from Book import Book + +class Library: + def __init__(self): + self.books = [] + + def add_book(self, book: Book): + if (not isinstance(book, Book)): + raise TypeError(f"Esperado Livro obtido valor {book} do tipo {type(book)}") + self.books.append(book) + + + + + + + + + + + + + + + # self.books = [] + + # def add_books(self, book: Book): + # if(isinstance(book) != Book) + # raise TypeError(f"Esperado Livro obtido valor {book} do tipo {type(book)}") + # self.books.append(book) \ No newline at end of file diff --git a/exercicios/para-casa/ShowBooks.py b/exercicios/para-casa/ShowBooks.py new file mode 100644 index 0000000..2c8207c --- /dev/null +++ b/exercicios/para-casa/ShowBooks.py @@ -0,0 +1,11 @@ +from Book import Book +from Library import Library + +class ShowBooks: + def __init__(self, name, author, year, comentary): + self.name = name + self.author = author + self.year = year + self.comentary = comentary + self.show = True + \ No newline at end of file diff --git a/exercicios/para-casa/__init__.py b/exercicios/para-casa/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/exercicios/para-casa/testBook.py b/exercicios/para-casa/testBook.py new file mode 100644 index 0000000..f8e84c7 --- /dev/null +++ b/exercicios/para-casa/testBook.py @@ -0,0 +1,20 @@ +from unittest import TestCase +from Book import Book + +class TestBook(TestCase): + def test_init_must_pass(self): + #Arrange + name = "Calibã e a Bruxa" + author = "Silvia Federici" + year = "1996" + comentary = "Bla" + + #Act + book = Book(name, author, year, comentary) + + #Assert + self.assertEqual(name, book.name) + self.assertEqual(author, book.author) + self.assertEqual(year, book.year) + self.assertEqual(comentary, book.comentary) + self.assertEqual(False, book.borrowed) \ No newline at end of file diff --git a/exercicios/para-casa/testLendBook.py b/exercicios/para-casa/testLendBook.py new file mode 100644 index 0000000..3a29374 --- /dev/null +++ b/exercicios/para-casa/testLendBook.py @@ -0,0 +1,16 @@ +from unittest import TestCase +from Bookstolend import BooksToLend +from Library import Library + +list_books = ["Calibã", "The Lion King: The Gift", + "The Witcher", "Nanatsu no Taizai", "The Hunger Games"] + +class TestLendBook(TestCase): + def test_init_lend_book(self): + + + name = list_books + + book = BooksToLend(name) + + self.assertEqual(name, book.name) \ No newline at end of file diff --git a/exercicios/para-casa/testLibrary.py b/exercicios/para-casa/testLibrary.py new file mode 100644 index 0000000..894899e --- /dev/null +++ b/exercicios/para-casa/testLibrary.py @@ -0,0 +1,40 @@ +from unittest import TestCase +from Library import Library +from Book import Book + +class TestLibrary(TestCase): + #Arrange / Act + library = Library() + def setUp(self): + self.library = Library() + + def test_unit_must_pass(self): + #Arrange / Act + #library = Library() + + #Asset + self.assertIsInstance(self.library.books, list) + + def test_add_book_must_pass(self): + #Arrange + #library = Library + book_name = "O mito da Beleza" + book_author = "Naomi Wolf" + book_year = "1996" + book_comentary = "Bla" + book = Book(book_name, book_author, book_year, book_comentary) + + #Act + self.library.add_book(book) + + #Assert + self.assertEqual(1, len(self.library.books)) + + def test_add_book_not_must_insert_number(self): + #Arrange + #library = Library() + book = 1988 + + #Act / Assert + with self.assertRaises(TypeError): + self.library.add_book(book) \ No newline at end of file diff --git a/exercicios/para-casa/testShowBooks.py b/exercicios/para-casa/testShowBooks.py new file mode 100644 index 0000000..45d9b5a --- /dev/null +++ b/exercicios/para-casa/testShowBooks.py @@ -0,0 +1,19 @@ +from unittest import TestCase +from Book import Book +from Library import Library + +class TestShowBooks(TestCase): + def test_init_show_books(self): + self.show_books= [] + + name = "The Lion King:The Gift" + author = "Beyoncé Carter Knowles" + year = "2019" + comentary = "Beyoncé called the album sonic cinema and said that the film is a new experience of storytelling, and that the album is influenced by everything from R&B, pop, hip hop and Afrobeats. Beyoncé also said that wanted to put everyone on their own journey to link the storyline and that the songs were inspired by the remake's storyline, which gives the listener a chance to imagine their own imagery, while listening to a new contemporary interpretation. The songs were also produced by African producers, which Beyoncé said was because authenticity and heart were important to, since the film is set in Africa." + + book = Book(name, author, year, comentary) + + self.assertEqual(name, book.name) + self.assertEqual(author, book.author) + self.assertEqual(year, book.year) + self.assertEqual(comentary, book.comentary) \ No newline at end of file