Added unit tests to repo
Closes #10 (closed)
This MR addresses the need for the automated unit tests requested through Anders' software review #1 (closed) .
There are a couple remaining blockers in the implementation of these units tests - mainly, getting git-ci.yml to pass
In this MR, I've added 4 scripts in the new folder tests/
. Each script test respective functions that are in src/
folder. Each test script is fairly simple right now. I don't think we need to add too much to it, but feel free to suggest additional unit tests to add as asserts
. I also added a conftest.py script in the root dir. This script is used to set configurations for pytest, I added it to add the specific path to the functions in the event that I want to test a specific tests/test_*.py
script.
I also committed a new empty folder in `tests/` called working_files
that serves as the location for the outputs of the test functions. (note that I am hoping to move this to a temp folder that is created and removed in the git-ci.yml
but I will not do this until the ci passes and I can get the environment built in gitlab).
How to Review:
To review the new unit test scripts, please:
-
pull this branch
-
rebuild the env (I changed the name to
hyswap-geospatial-data-assembly-env
and edited a couple libraries) -
run
pytest
in the gitbash command line, OR runpytest tests/test_*.py
to test a specific test script). -
Check that the tests pass. You should see a output in the console like this:
(hyswap-geospatial-data-assembly-env) IGSARMEWLTMSLE:/ msleckman$ pytest ====================================================================================================== test session starts ====================================================================================================== platform darwin -- Python 3.11.6, pytest-8.1.1, pluggy-1.5.0 rootdir: ~/hyswap-geospatial-data-assembly plugins: anyio-4.3.0, requests-mock-1.12.1 collected 4 items tests/test_collate_drainage_area.py . [ 25%] tests/test_create_geom_inter.py . [ 50%] tests/test_fetch_nhdplus.py . [ 75%] tests/test_fetch_states.py . [100%] ======================================================================================================= warnings summary ======================================================================================================== ~/miniconda3/envs/hyswap-geospatial-data-assembly-env/lib/python3.11/site-packages/sciencebasepy/SbSession.py:17 ~/envs/hyswap-geospatial-data-assembly-env/lib/python3.11/site-packages/sciencebasepy/SbSession.py:17: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html from pkg_resources import get_distribution src/collate_drainage_area_basins.py:4 ~/hyswap-geospatial-data-assembly/src/collate_drainage_area_basins.py:4: DeprecationWarning: GeoPandas is set to use PyGEOS over Shapely. PyGEOS support is deprecatedand will be removed in GeoPandas 1.0, released in the Q1 of 2024. Please migrate to Shapely 2.0 (https://geopandas.org/en/stable/docs/user_guide/pygeos_to_shapely.html). import geopandas as gpd -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================================================================================== 4 passed, 2 warnings in 116.86s (0:01:56) ===========================================================================================
Next issues to address:
-
As mentioned, the environment.yml
is not successfully building ingit-ci.yml
. I am able to build it locally however. I believe this is due to the build ofpynhd=0.15.2
. Next mr should work to address this. -
Clean some packages we absolutely DO NOT need in the environment yml. This should be addressed through #9 (closed)