def test_add_book(self, mock_print, mock_input): main.main() # reset counter and make book that mimics the one expected to be created Counter.reset_counter() expected_book = Book('Title', 'Author', False) all_books = self.store.get_all_books() self.assertEqual(expected_book, all_books[0])
def test_string(self): Counter.reset_counter() bk = Book('AAAA', 'BBBB', True) self.assertIn('1', str(bk)) # ID should be 1 self.assertIn('AAAA', str(bk)) self.assertIn('BBBB', str(bk)) self.assertIn('You have read', str(bk))
def test_create_book_id_increases(self): Counter.reset_counter() bk = Book('Title', 'Author') self.assertEqual(1, bk.id) bk2 = Book('Title2', 'Author2') self.assertEqual(2, bk2.id) bk3 = Book('Title3', 'Author3') self.assertEqual(3, bk3.id)
def setUp(self): self.store = BookStore() self.store.delete_all_books() Counter.reset_counter()
def test_counter(self): Counter.reset_counter() self.assertEqual(1, Counter.get_counter()) self.assertEqual(2, Counter.get_counter())