To design, implement and test the Search and Book Page of the Harvard CS50 Project 1. - ndvssankar/Web-Programming GitHub Wiki
Welcome to the Web-Programming wiki!
Design:
The following are the UI fields with respect to search task:
- There will be an input box where the user can type his/her ISBN, title, author of the book.
- There will be a Search button and when clicked, the related books on the same page.
The following are the UI fields with respect to Book_page task: The details of the book will be displayed when the user selects the book from the search results. The details can be as follows
- Its title
- Author
- Publication year
- ISBN number
- Reviews that users have left for the book on your website.
Implementation:
The following are the things to be considered for implementation for search page: When the user enters the text and clicking on the button, it should redirect to /search app.route that routes to a search function.
- Get the data from the form
- Use SQLAlchemy to get the book results based on the search query (There will be a Book entity).
- Display the results in a tabular format with each book having the hyperlink as its ISBN number. /book_page?isbn_number=isbn_number can be used as a URL.
- The above URL can be used to redirect to Book_page that displays the book details.
The following are the things to be considered for implementation for Book_page. When the user clicks on the link that has displayed on the search results page, will redirects to /book_page app.route that routes to a book_page python function.
- Get the ISBN number from the URL.
- Issue the query to the database in order to get the book details.
- Render the HTML page (book_page.html) with the book details.
Testing:
Check for the following test cases on the search function.
- One test case with existing ISBN number
- One test case with book name
- One test case with author name
- One test case with invalid ISBN number
- One test case with invalid book name
- One test case with invalid author name
- One test case with valid publishing year
- One test case with invalid publishing year
- One test case with valid wild card characters and that has partial book / author name / ISBN number.
- One test case with no text in the text box and hit the search button. Then the user will asked to enter the valid text in the search text box.
The following is with Book_page test case that works on book_page function. 11. Check whether the URL has an ISBN Number.