Skip to content
LaxmiNarayanaMurthyVemuri edited this page Mar 31, 2020 · 5 revisions

Design

  1. After user logs in it redirects to index method as GET request with URI "/".
  2. We want to provide user a search option with the selected drop-down with options like ISBN, title, author and year and textbox to enter the string he wants to search with and submit button. After submitting all the required details, the index() method should be called with URI "/" as a POST request.
  3. After redirecting to URI "/", From the above-selected option, the search will look up from the database based on the drop-down option selected.
  4. After the search is successful (If the search matches with any of the books in the database), below it, a list of books is displayed with ISBN values with hyperlinks of format "/books/ISBN = isbn_number".
  5. If the search string doesn't matchbooks in the database, we will redirect to page to "/" with a message "No results found for your search".

Steps to implement the Search

  • API route: /
  • GET and POST methods
  • GET - render the page with a search option for the user, no books displayed in it.
  • POST - do the search with text provided by the user. (perform the DB operation here, using LIKE) Books will be displayed based on the search string.

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_search(), this function tests the functionality by passing correct arguments like isbn, book, author, and title to the application and validates the application
  2. test_invalid_search_year(), this function tests the functionality by passing incorrect arguments to the application like an invalid year and validates the application
  3. test_invalid_search_isbn(), this function tests the functionality by passing incorrect arguments to the application like an invalid isbn and validates the application
  4. test_invalid_search_author(), this function tests the functionality by passing incorrect arguments to the application like an invalid author and validates the application
  5. test_invalid_search_name(), this function tests the functionality by passing incorrect arguments to the application like an invalid title and validates the application
Clone this wiki locally