def test_remove_missing_record(self):
     database = BookDataBase(self.file)
     book = Book("What", "Steven Law", 2000, "Thriller", 0.2, 3)
     with open(self.file, 'w') as file:
         file.write("What+Steven Maw+2000+Thriller+0.2+20\n")
         file.write("Go+Steven Law+2000+Thriller+0.2+20\n")
     with self.assertRaises(MissingBookError):
         database.remove_record(book)
 def test_remove_record(self):
     database = BookDataBase(self.file)
     book = Book("What", "Steven Law", 2000, "Thriller", 0.2, 3)
     book1 = Book("What", "Steven Maw", 2000, "Thriller", 0.2, 20)
     book2 = Book("Go", "Steven Law", 2000, "Thriller", 0.2, 20)
     booklist = [book, book1, book2]
     recordlist = [book.special_record() for book in booklist]
     with open(self.file, 'w') as file:
         file.write("What+Steven Law+2000+Thriller+0.2+3\n")
         file.write("What+Steven Maw+2000+Thriller+0.2+20\n")
         file.write("Go+Steven Law+2000+Thriller+0.2+20\n")
     database.remove_record(book2)
     del recordlist[2]
     with open(self.file, 'r') as file:
         records_after_removal = file.readlines()
     self.assertEqual(recordlist, records_after_removal)
     database.remove_record(book)
     del recordlist[0]
     with open(self.file, 'r') as file:
         records_after_removal = file.readlines()
     self.assertEqual(recordlist, records_after_removal)
     os.remove(os.path.realpath(self.file))