test(backend): add endpoint tests for feedback, stars, and notifications apps (#229)#506
Open
ShawK91 wants to merge 1 commit into
Open
Conversation
…ons apps Adds API test coverage for three previously-untested apps (hotosm#229): - feedback: auth required, create sets request user, GeoJSON response shape, invalid geometry/action rejected, stac_id/action filters, owner-only update/delete (IsOwnerOrAdminOrReadOnly) - stars: target_id validation, anonymous star dedupe via IP+UA hash, distinct anon clients counted separately, authed star/unstar state, anon unstar removes only own star - notifications: public banner list hides unstarted banners, expired banners flagged not displayable, per-user notification scoping, mark-read / mark-all-read behavior incl. cross-user isolation Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or 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
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.
What
Contributes to #229 by adding 21 endpoint tests for the three backend apps that currently have no test coverage:
feedback,stars, andnotifications(datasets, predictions, and trainings already have suites underbackend/tests/).Coverage added
test_feedback_endpoints.py(8 tests) - authentication required; create assigns the request user; GeoJSON Feature response shape; invalid geometry and unknown action rejected (400);stac_id/actionfilters; reads allowed for non-owners while update/delete is owner-only (IsOwnerOrAdminOrReadOnly), including verifying a denied PATCH leaves the row unchanged.test_star_endpoints.py(7 tests) -target_idvalidation on GET/POST; anonymous star dedupe via the hashed IP+UA key (repeat click ->created: false, count unchanged); distinct anonymous clients counted separately; authenticated star/unstar state transitions; anonymous unstar removes only its own star.test_notification_endpoints.py(6 tests) - banner list is public and hides not-yet-started banners; started-but-expired banners are listed withis_displayable: false; notification list requires auth and is scoped per-user;mark-readsetsread_atand 404s on another user's notification;mark-all-readleaves other users' notifications untouched.Tests follow the existing
backend/tests/conventions (pytest fixtures,APIClient.force_authenticate).Verification
ruff check/ruff formatclean on the three new files.Developed alongside Claude Fable 5.