def test_add_book_will_error_when_rating_greater_than_5(self): # test that addBook adds the correct bookName in new entry in bookLst # Set up testName = 'Diana McSpadden' testEmail = '*****@*****.**' testGenre = 'Historical Fiction' testBookNum = 2 testBookLst = [('Black Hills: A Novel',4),('The Red Tent',5)] # create initial bookLvr bookLvr1 = BOOKLOVER(testName, testEmail, testGenre, testBookNum, testBookLst) # when adding a book with a rating greater than 5 test that the correct error is returned with self.assertRaisesRegexp(ValueError, 'A book rating must be between 0 and 5.'): #use assertRaisesRegexp with a literal of the customer ValueError message bookLvr1.addBook('My Name Is Vittoria',6)
def test_add_book_adds_correct_entry_to_bookLst(self): # test that addBook adds the correct bookName in new entry in bookLst # Set up testName = 'Diana McSpadden' testEmail = '*****@*****.**' testGenre = 'Historical Fiction' testBookNum = 2 testBookLst = [('Black Hills: A Novel',4),('The Red Tent',5)] # create initial bookLvr bookLvr1 = BOOKLOVER(testName, testEmail, testGenre, testBookNum, testBookLst) # add a book bookLvr1.addBook('My Name Is Vittoria',3) # retrieve last item in book list bookLvrLastBook = bookLvr1.bookLst[-1] # test whether the last item in the list is the book added self.assertEqual(bookLvrLastBook, ('My Name Is Vittoria',3))