Skip to content

Book page

LaxmiNarayanaMurthyVemuri edited this page Mar 31, 2020 · 8 revisions

Design

  1. This task is an extension of the previous task. After the search results are populated in the table-wise. ISBN column of the table will have hyperlinks in format "/books?ISBN=isbn_no".
  2. If the users select any book with ISBN number displayed in the table, it will redirect to a new page that has details of books like ISBN, title, author and year of the book.

Steps to implement the Book Page

  • API route: /books, it takes a parameter ISBN
  • GET method
  • GET - render the page with book information by querying the database by ISBN number

Functionality

  • The route for the function is /books?isbn=ISBN and it redirects to book_details() with URI "/books".
  • In book_details() Query the database for book details like author, title, year and reviews based on the ISBN parameter in the URL.
  • Rendering these details to book_detail.html page bypassing book as a parameter using jinja templates

Testing

The unittest testing framework was originally inspired by JUnit and has a similar flavor as major unit testing frameworks in other languages. It supports test automation, sharing of setup and shutdown code for tests, aggregation of tests into collections, and independence of the tests from the reporting framework.

To achieve this, the unit test supports some important concepts in an object-oriented way:

  1. test_valid_bookdetails(), this function tests the functionality by passing correct arguments like isbn to the application and validates the application
  2. test_invalid_bookdetails(), this function tests the functionality by passing incorrect arguments to the application like an invalid isbn and validates the application
Clone this wiki locally