Beispiel #1
0
def test_Book():
    book = Book("title", "author", "description")
    assert book.getTitle() == "title"
    assert book.getAuthor() == "author"
    assert book.getDescription() == "description"
    book.setBorrowed(True)
    assert book.isBorrowed() == True
    book.setAuthor("new author")
    assert book.getAuthor() == "new author"
    book.setDescription(None)
    book.setTitle("new title")
    assert book.getTitle() == "new title"
    book.setPopularity(1)
    assert book.getPopularity() == 1
    assert book.getDescription() == None
    book.setId(0)
Beispiel #2
0
def test_Book():
    book = Book("title", "author", "description")
    assert book.getTitle() == "title"
    assert book.getAuthor() == "author"
    assert book.getDescription() == "description"
    book.setBorrowed(True)
    assert book.isBorrowed() == True
    book.setAuthor("new author")
    assert book.getAuthor() == "new author"
    book.setDescription(None)
    book.setTitle("new title")
    assert book.getTitle() == "new title"
    book.setPopularity(1)
    assert book.getPopularity() == 1
    assert book.getDescription() == None
    book.setId(0)
Beispiel #3
0
 def addNewBook(self, title, author, description):
     """
     Public method that overwrites the one in the BookList
     Extra functionality: Appends the newly added Book to the file
     O(1)
     """
     self.bookFile = open(self.__filename, "a")
     book = Book(title, author, description)
     errorList = self.validator.validateBook(book)
     if errorList != []:
         return errorList
     self.bookList.append(book)
     self.bookFile.write(book.getTitle() + "|" + book.getAuthor() + "|" + book.getDescription() + "|" + \
                         "False" + "|" + "0" +"\n")
     self.bookFile.close()
Beispiel #4
0
 def addNewBook(self, title, author, description):
     """
     Public method that overwrites the one in the BookList
     Extra functionality: Appends the newly added Book to the file
     O(1)
     """
     self.bookFile = open(self.__filename, "a")
     book = Book(title, author, description)
     errorList = self.validator.validateBook(book)
     if errorList != []:
         return errorList
     self.bookList.append(book)
     self.bookFile.write(book.getTitle() + "|" + book.getAuthor() + "|" + book.getDescription() + "|" + \
                         "False" + "|" + "0" +"\n")
     self.bookFile.close()