def test_create_book_with_invalid_isbn_raises_error(self): publisher = PublisherFactory() author = AuthorFactory() new_book = Book( author=author, publisher=publisher, isbn='ISBN', title='Test book' ) with self.assertRaises(ValidationError): new_book.save() new_book.full_clean()
def test_cannot_save_book_without_author(self): book = Book(title="Test book", year=2000) with self.assertRaises(ValidationError): book.full_clean()
def test_cannot_save_empty_book(self): book = Book() with self.assertRaises(ValidationError): book.full_clean()