예제 #1
0
 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])
예제 #2
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))
예제 #3
0
    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)
예제 #4
0
 def setUp(self):
     self.store = BookStore()
     self.store.delete_all_books()
     Counter.reset_counter()
예제 #5
0
 def test_counter(self):
     Counter.reset_counter()
     self.assertEqual(1, Counter.get_counter())
     self.assertEqual(2, Counter.get_counter())