I first modified all current test cases by pointing them to the proper imports and removing unneeded imports.
For all of the test files, we will now run them using the Firebase Emulator. This lets us properly test our routes while not interacting with the database which fixes issue #64 .
I then modified the test cases in order from top-down:
I used the ChatGPT reference for the above file to help refactor the test cases and properly validate the create_user() and delete_user() tests. I added mock_data into the file for proper validation that the return would be what is expected.
test_get_update_user.py
After finishing the create and delete routes, I modified the get and update routes using the above info. Once again, I added mock data for proper validation and insertion for the update route.
I refactored the above 2 files into a new file called test_users.py which just moved the above code into a single file to simplify our test suite.
test_post_validation
We created the post_validation and user_validation functions as temporaries to validate our data for developing proper routes in the backend. All post, user, and recipe requests will be validated by the front end so we no longer need this test.
test_posts
I used the test_user file above to modify the test_posts file and properly create a new user to insert from, added that user to the author field of some mock data in a post, and then properly tested all four; create, update, get, and delete, post routes, and then deleted that user.
run_tests.py
This is the script that runs all the above test files. After moving the routes themselves into different files for proper Flask Blueprint separation, this script did not return the proper information. I added the new files user_routes, post_routes, feed_routes, and recipe_routes to the source array in the run_tests file to properly display the coverage. The server file only holds the middleware request interception, so I removed the server from the source array as it is skewing our coverage results.
Added emulator files to .gitignore so that Firebase Emulator information is not pushed to the github.
Screenshots (Optional)
How to Test
_Start the Firebase Emulator (follow steps in issue #65 if you haven't) and make sure server.py is interacting with the emulator. We do not want to run the testsuite on the actual database!
_Comment out the @app.before_request line in the server.py file which runs the middleware. The test suite does not account for proper authentication and this change is needed to verify the routes work as intended without the middleware verification._
_Run the run_tests.py test suite in the backend folder to run all test scripts and display a coverage report._
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.
Fixes #64
Description / Changes Made
test_users
test_create_delete_user.py
: ChatGPT Referencetest_get_update_user.py
test_post_validation
test_posts
run_tests.py
user_routes
,post_routes
,feed_routes
, andrecipe_routes
to the source array in the run_tests file to properly display the coverage. The server file only holds the middleware request interception, so I removed the server from the source array as it is skewing our coverage results.Screenshots (Optional)
How to Test
@app.before_request
line in the server.py file which runs the middleware. The test suite does not account for proper authentication and this change is needed to verify the routes work as intended without the middleware verification._run_tests.py
test suite in the backend folder to run all test scripts and display a coverage report._Checklist