def book_details_web_api(): isbn_number = request.args.get("isbn_number") book = get_book_details(isbn_number) if book is None: return jsonify({"Error": "Invalid ISBN number"}), 422 elif book: return jsonify({ "ISBN": book.isbn, "Title": book.title, "Author": book.author, "Year": int(book.year) }), 200 else: return jsonify({"Error": "Server not ready to serve api requestss"}), 500
def book_page(): isbn_number = request.form["isbn_number"] # username = request.session["USERNAME"] username = "******" if (isbn_number == None or len(isbn_number) == 0): flash("Invalid ISBN Number") return render_template("book_page.html", book=None) if not username: flash("Your session is closed.. Please login again") return redirect(url_for("register")) else: book = get_book_details(isbn_number) if book is None: flash("Invalid ISBN Number") return render_template("book_page.html", book=None) else: return render_template("book_page.html", book=book)
def test_valid_isbn_book_details_2(self): book = get_book_details("080213825X") self.assertEqual(book.title, "Four Blondes")
def test_invalid_isbn_book_details(self): book = get_book_details() self.assertEqual(book, None)
def test_valid_isbn_book_details_1(self): book = get_book_details("1416949658") self.assertEqual(book.title, "The Dark Is Rising")