def test_delete_book(self, patched_query, patched_session): mock_filter_by = Mock() patched_query.filter_by.return_value = mock_filter_by mock_filter_by.delete.return_value = True isbn = 'fake_isbn' Book.delete_book(isbn) patched_query.filter_by.assert_called_with(isbn=isbn) mock_filter_by.delete.assert_called_once() patched_session.commit.assert_called_once()
def delete_book(isbn): if not Book.delete_book(isbn): abort( 404, "Book with ISBN number provided not found, so unable to delete.") return jsonify(dict()), 204