_I implemented the routes for liking and unliking posts.
Routes can be accessed by /api/users//(un)like/ and a PATCH request. These routes don't need any json body data, only the user_id that is trying to (un)like a specific postid.
_This route adds/removes a reference to a post in the user collection (user_id), and increases/decreases the number of likes in the post collection (postid).
_I also modified the middleware function to return a proper error message when a authorization header is not provided, as well as updated the method for retrieving the api_name and apiaddress to reflect the new routes created.
_Server.py has also been modified to properly register the new like blueprint for the new file likeroutes.py that was created.
I also modified all PUT routes to properly use a PATCH request for partial updating of data and adjusted the middleware accordingly.
_I also wrote the test case for the like routes in file test_likes.py: ChatGPT Reference_
_I modified the ChatGPT reference to import packages properly as well as to use a specific user id and pull back the new post id from that user id. I also added the cases for when the post was not liked and unlike successfully which brought the coverage for likeroutes up to 100%!
How to Test
_Comment out the @app.before_request line in the server.py file. We do not need to run the middleware function while testing our routes._
Run the Firebase Emulator. We do not want to test on the database
_Run the test_suite: python run_tests.py_
Screenshots
Checklist
[x] I have added/updated relevant documentation, and I have followed the coding style guidelines.
[x] I have added/updated tests, and I have run the test suite and all tests pass.
[x] I have checked for any potential conflicts with other branches and fixed any merge conflicts.
[x] I have verified all routes still function properly.
[x] I have verified middleware still works properly and only allows access to routes the user should have access too.
Description / Changes Made
test_likes.py
: ChatGPT Reference_How to Test
@app.before_request
line in theserver.py
file. We do not need to run the middleware function while testing our routes._python run_tests.py
_Screenshots
Checklist