-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mc add endpoint tests #14
Conversation
The refactoring involved moving the initialization of the psycopg2 connection out of the create_app function and into its parameter list. This allows the function to be more flexible and reusable, capable of accepting different database connections. It allows for easier testing and potential use with different database management systems in the future.
This commit includes the creation of a new file, test_endpoints.py, specifically dedicated to thoroughly testing the functionality of all application endpoints. It utilizes Pytest to ensure that each endpoint correctly calls (or doesn’t call) the appropriate methods in their supporting classes, as per the original design. The test checks both allowed and not allowed methods for each endpoint.
The test_app_with_mock fixture in app_test.py has been simplified. The mocker from pytest-mock has been utilized to replace the previously used patch and MagicMock. Node assertions for database interaction have been removed from the endpoint test function.
@maxachis nice. outside of API endpoints, what are the ways that the database can change, currently? |
@josh-chamberlain If you're talking about how the schema can change, at the moment we're looking mostly at the removal of a view columns or the normalization of tables. However, all of this would be on pause until I finish setting up a suite of integration tests which will give us confidence that any changes I make aren't breaking things substantially. I think that answers your question, but if you meant something else, let me know! |
@maxachis I meant data in the database—are we programmatically making changes to the data without using the API anywhere? |
@josh-chamberlain A few places. Things such as the Google Agency searcher, as designed, would be inserting data directly into the database. And then there are some things, such as user roles, which don't appear to be governed by an API endpoint and so must be modified through direct SQL queries. As a heuristic (for my own sake rather than yours), any SQL string located in a file that isn't in the data-sources-app repository (and isn't a test) would strongly suggest someplace that's modifying the database outside of an endpoint. |
@maxachis thanks. plus, probably only a few python files should contain endpoints...I made a new issue: Police-Data-Accessibility-Project#315 |
Fixes
Description
Refactor create_app Function in app.py
Cleaned up the PsycopgResource class by removing methods that were not being used.
Add Thorough Tests for All Application Endpoints
Testing
test_endpoints.py
Performance
Docs