Skip to content

BDMS 55: thing coverage & other updates#108

Merged
jirhiker merged 23 commits into
pre-productionfrom
jab-api-coverage-thing
Aug 28, 2025
Merged

BDMS 55: thing coverage & other updates#108
jirhiker merged 23 commits into
pre-productionfrom
jab-api-coverage-thing

Conversation

@jacob-a-brown

Copy link
Copy Markdown
Contributor

Why

This PR addresses the following problem / context:

  • The thing router should be fully covered with GET, GET by ID, POST, PATCH, and DELETE endpoints
  • Tests that relied on spillover need to be amended for the use of fixtures
  • Proper authentication and permissions need to be vetted at endpoints
  • A Location's name needs to be editable in a PATCH request
  • Sessions weren't always properly closed, leading to errors in tests

How

Implementation summary - the following was changed / added / removed:

  • Added GET requests for /thing/water-well, /thing/water-well/{thing_id}, /thing/spring/{spring_id}
  • Added GET request for /thing/water-well/{thing_id}/well-screen
  • Added GET request for /thing/id-link/{link_id}
  • Removed thing_type query parameter from GET /thing as that is now handled as a path parameter
  • Renamed POST /thing/well to POST /thing/water-well to correspond with the current thing type
  • Removed POST /thing so that things of a particular thing_type can be created. This restricts the values that can be populated and ensures there is no spillover into a field for a wrong thing_type
  • Added PATCH /thing/water-well/{thing_id} and PATCH /thing/spring/{thing_id}
  • Removed PATCH /thing so that fields can only be edited that correspond with the correct thing_type
  • Added DELETE /thing/{thing} (since the type doesn't matter for deletion), /thing/well-screen/{well_screen_id}, /thing/id-link/{link_id}

Notes

Any special considerations, workarounds, or follow-up work to note?

  • When getting, posting, or patching a thing of a particular type its thing_type is deduced by the request/path parameter
    • thing_type is still a viable argument for add_thing since that is used in the data transfer. That argument is not, however, to be used in the API and endpoints.
  • Since thing_type is vital information for getting, posting, and patching a Thing thing_helper.py was updated to have custom getting, posting, and patching functions

@codecov-commenter

codecov-commenter commented Aug 28, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.57265% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
api/thing.py 97.87% 2 Missing ⚠️
services/thing_helper.py 98.64% 1 Missing ⚠️
Files with missing lines Coverage Δ
schemas/location.py 90.90% <100.00%> (ø)
schemas/thing.py 98.88% <100.00%> (+0.90%) ⬆️
tests/conftest.py 100.00% <100.00%> (ø)
tests/test_asset.py 100.00% <100.00%> (ø)
tests/test_contact.py 100.00% <100.00%> (ø)
tests/test_geospatial.py 87.75% <100.00%> (+0.12%) ⬆️
tests/test_location.py 100.00% <100.00%> (ø)
tests/test_observation.py 96.69% <100.00%> (ø)
tests/test_sample.py 100.00% <100.00%> (ø)
tests/test_search.py 91.46% <100.00%> (ø)
... and 3 more

... and 5 files with indirect coverage changes

@jirhiker jirhiker merged commit 05963f7 into pre-production Aug 28, 2025
3 checks passed
@jirhiker jirhiker deleted the jab-api-coverage-thing branch December 3, 2025 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants