Mr. Librarian
Technologies Used
- Vanilla Python
- Requests Library
- Postman
- Argparse Library
- Unittest Library
Description
Mr. Librarian is a command-line application that uses the Google Book's API to retrieve book information for users. The application also allows users to store their favorite books in a reading list for access in the future.
Project Difficulties
The most difficult part of this project involved writing the unit tests for the database queries and for the function responsible for making the API call. When running the tests, I noticed that they actually made interacted with the database and that they made the API call. This resulted in erroneous data in the database and it meant that my tests were dependent on the state of external dependencies.
My Solution
The solution to this problem was to introduce patches from the unittest.mock library. These patches essentially allowed the tests to create a mock object that would act as a substitute for the database and the request call. Now, instead of actually The creation of these "dummy" objects allowed the unit tests to isolate and test the functionality of each method, without having to worry about the behavior of the external dependencies.