-
Notifications
You must be signed in to change notification settings - Fork 15
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
Setup testing #67
Merged
Merged
Setup testing #67
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 tasks
for more information, see https://pre-commit.ci
It's a pretty big PR so let me know if you'd like me to break it up into smaller PRs or something different to make it more digestible @g4brielvs |
@elbeejay Many thanks! I have prioritized and will review it shortly. |
g4brielvs
approved these changes
Jul 29, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tests for the GOSTnets package
This PR provides both unit and integrative tests for the GOSTnets package.
In total, this PR includes 91 tests, covering 72% of the codebase (2072 lines of code).
Running the test suite
A new CI workflow (test.yml) was added to automatically run the tests on pushes and pull requests. If desired, we can work to add a "coverage badge" that displays the percentage of code covered by the test suite on the README or something along those lines.
To run the test suite locally, you can follow the instructions in the CI workflow, which are to clone the repository, and then install the [dev] version of the package:
pip install .[dev]
. Then you can run the test suite with the commandpytest
. If you are interested in the code coverage, you should use thecoverage
tool to run pytest:coverage run -m pytest
, after the tests run, you can view coverage in the terminal withcoverage report
, or generate a nice HTML view withcoverage html
which enables you to look at the specific lines of code covered and not covered by the tests.Unit Tests
There are 79 "unit" tests that aim to atomically test and validate the performance of individual functions. These tests sometimes involve "mocking" of functions, objects, or data to isolate the functionality of each individual function (in normal use, functions may call each other, or rely on outputs from other functions as their input).
Integrative Tests
There are 12 "integrative" tests that are more similar to example workflows and test the functions on test data. As opposed to the "unit" tests that aim to test each function in isolation, the integrative tests allow functions to call nested functions and so-on, just as they would when the package is being used normally.
Missing Tests
This PR implements tests that call 72% of the lines of code in the GOSTnets package. Lines of code that are untested include:
osm_parser.py
:download_osm()
is untestedread_osm()
is untestedload_osm.py
OSM_to_network.fetch_roads()
andOSM_to_network.fetch_roads_and_ferries()
OSM_to_network.initialReadIn()
core.py
node_gdf_from_graph()
edge_gdf_from_graph()
graph_nodes_intersecting_polygon()
andgraph_edges_intersecting_polygon()
sample_raster()
assign_traffic_times()
is untested because it requires a Mapbox token (and in lieu of that I don't have my hands on sample data)calculate_OD()
simplify_junctions()
andpandana_snap()
(and similar functions)join_networks()
is currently untested as I couldn't come up with a simple case that worked thereupdate_nodes()
is untested as the parameter arguments need to be revised and some input handling logic is needed to ensure the appropriate optional parameters are provided based on the method being employedupdated_edges()
is untested because a large number of variables within the function are never definedHowever given the fact that we've achieved coverage of the majority of code and functionlity, I believe it is reasonable to merge this PR in now. Some of the tests to write in the future will require detailed updates of the functions themselves, which may be best done on a single case-by-case basis to make the review of the PR easier.
This PR already does some minor editing to functions as needed due to deprecation of parameters and other changes in upstream dependencies.