To be able to quickly test the code from lesson 1 manually, a new file was created, menu.py
, which allows exercising all basic functionality in main.py
. However, it was coded in such a rush that there are several bugs that have to be fixed before it can be used. Once that is done, we need to implement logging functionality on two of the files in the project.
-
Make sure you can complete all the steps outlined in "Testing
menu.py
" below. This will not be as easy as it sounds. The code HAS errors that you will need to debug and fix. You can use PDB, Pysnooper or any other debugging techniques you like. Make sure you capture your findings in a file calleddebugging_notes.md
(same markup format used for this README file). This file must be submitted with the rest of your work. -
Implement logging capabilities on
users.py
anduser_status.py
:- You can use the standard Python logger or Loguru.
- Both
users.py
anduser_status.py
will share a single log file per session. - Each class method should have at least one log info message. For example, "New status collection instance created".
- Within each method, you should have one log error message before the method returns
False
. - You can also add logging to
main.py
andmenu.py
, but it is not a requirement.
- Load the users database.
- Add a new user and confirm you get a success message.
- Try to add the same user ID again and confirm you get an error message.
- Update the name of an existing user.
- Try to update the name of a non-existing user and confirm you get an error message.
- Search for an existing user and return that user's email, name and last name.
- Search for a non-existing user and return a message indicating that the user does not exist.
- Delete an existing user.
- Try to delete a non-existing user and confirm you get an error message.
- Save the users database.
- Load the status database.
- Add a new status and confirm you get a success message.
- Try to add the same status ID again and confirm you get an error message.
- Update the text of an existing status ID.
- Try to update the text of a non-existing status ID and confirm you get an error message.
- Search for an existing status ID and return the ID of the user that created the status and the status text.
- Search for a non-existing status ID and return a message indicating that the status ID does not exist.
- Delete an existing status.
- Try to delete a non-existing status and confirm you get an error message.
- Save the status database.
- Make sure menu options are case-insensitive (i.e., typing "a" or "A" works in the same way).
- Log filename: Each time you launch
menu.py
, it will create a file calledlog_mm_dd_yyyy.log
which will reflect the date on which the server is being launched, for example:log_10_22_2020.log
. If there is already a file with that name, your log messages will be appended to it (i.e., the existing log file will not be overwritten). Your log name can include additional information (for example, time at which it was launched). - PEP8 compliance: Your code will need to pass Pylint with 10 out of 10. As before, a custom .pylintrc file or Pylint disable comments directly on main.py can be used.
- If you use loguru for logging, enter all your
logger.add()
statements for logfile creation inmenu.py
. That will make it possible for all other files to share the same logfile.
The following files need to be submitted:
menu.py
main.py
(Your starting code should be the file you modified for assignment 1).users.py
(Your starting code should be the file you used for assignment 1).user_status.py
(Your starting code should be the file you used for assignment 1).debugging_notes.md
..pylintrc
(if using custom rules).
The instructor will do the following:
- Check that all errors in
menu.py
were corrected. - Check that a single log file is created with each run and that logging messages are being generated from both
users.py
anduser_status.py
. - Run Pylint to verify PEP8 compliance.