Ejemplo n.º 1
0
    def test_save_add_to_db(self):
        bk = Book(author='AAAA', title='BBBB', read=True)
        bk.save()
        self.assertIsNotNone(bk.id)  # Check book has ID

        self.assertEqual(bk, bookstore.get_book_by_id(bk.id))
        self.assertTrue(bookstore.exact_match(bk))
 def test_add_book_store_with_books_in(self):
     self.add_test_data()
     book_count = bookstore.book_count()
     bk = Book(title='aa', author='bbbbb')
     bk.save()
     self.assertTrue(bookstore.exact_match(bk))
     self.assertEqual(book_count + 1, bookstore.book_count())
Ejemplo n.º 3
0
    def test_save_update_changes_to_db(self):

        bk = Book(author='CCC', title='DDD', read=True)
        bk.save()

        # Change some attributes and save
        bk.author = 'EEE'
        bk.title = 'FFF'
        bk.read = False

        bk.save()

        # Check DB has same data as bk Book object
        self.assertEqual(bk, bookstore.get_book_by_id(bk.id))
        self.assertTrue(bk, bookstore.exact_match(bk))
 def test_delete_book(self):
     self.add_test_data()
     count = bookstore.book_count()
     bookstore.delete_book(self.bk2)
     self.assertEqual(count - 1, bookstore.book_count())
     self.assertFalse(bookstore.exact_match(self.bk2))
 def test_exact_match_not_found_empty_store(self):
     bk = Book(title='Whatever', author='Whatever')
     self.clear_bookstore()
     self.assertFalse(bookstore.exact_match(bk))
 def test_add_book_empty_store(self):
     bk = Book(title='aa', author='aaa')
     bk.save()
     self.assertTrue(bookstore.exact_match(bk))
     self.assertEqual(1, bookstore.book_count())
 def test_exact_match_not_found_title(self):
     self.add_test_data()
     bk = Book(title='Collection of Stories', author='Creative Creator')
     self.assertFalse(bookstore.exact_match(bk))
 def test_exact_match_not_found_title_author(self):
     self.add_test_data()
     bk = Book(title='Collection of Songs', author='Beyonce')
     self.assertFalse(bookstore.exact_match(bk))
 def test_exact_match_not_found_author(self):
     self.add_test_data()
     bk = Book(title='Collection of words', author='Someone Else')
     self.assertFalse(bookstore.exact_match(bk))
 def test_exact_match_found(self):
     self.add_test_data()
     bk = Book(title='Collection of words', author='Creative Creator')
     self.assertTrue(bookstore.exact_match(bk))
 def test_is_book_in_store_empty_list(self):
     self.clear_bookstore()
     not_in_store = Book(title='ccc', author='ddd')
     self.assertFalse(bookstore.exact_match(not_in_store))
 def test_is_book_in_store_not_present(self):
     not_in_store = Book(title='aaaa', author='bbbb')
     self.add_test_data()
     self.assertFalse(bookstore.exact_match(not_in_store))
 def test_is_book_in_store_present(self):
     self.add_test_data()
     self.assertTrue(bookstore.exact_match(self.bk1))
     self.assertTrue(bookstore.exact_match(self.bk2))
     self.assertTrue(bookstore.exact_match(self.bk3))