Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions exercicios/para-casa/Book.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions exercicios/para-casa/Bookstolend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class BooksToLend:
def __init__(self, name):
self.name = name
30 changes: 30 additions & 0 deletions exercicios/para-casa/Library.py
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 11 additions & 0 deletions exercicios/para-casa/ShowBooks.py
Original file line number Diff line number Diff line change
@@ -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

Empty file.
20 changes: 20 additions & 0 deletions exercicios/para-casa/testBook.py
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 16 additions & 0 deletions exercicios/para-casa/testLendBook.py
Original file line number Diff line number Diff line change
@@ -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)
40 changes: 40 additions & 0 deletions exercicios/para-casa/testLibrary.py
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 19 additions & 0 deletions exercicios/para-casa/testShowBooks.py
Original file line number Diff line number Diff line change
@@ -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)