Skip to content

test(backend): add endpoint tests for feedback, stars, and notifications apps (#229)#506

Open
ShawK91 wants to merge 1 commit into
hotosm:developfrom
ShawK91:test/229-endpoint-tests-feedback-stars-notifications
Open

test(backend): add endpoint tests for feedback, stars, and notifications apps (#229)#506
ShawK91 wants to merge 1 commit into
hotosm:developfrom
ShawK91:test/229-endpoint-tests-feedback-stars-notifications

Conversation

@ShawK91

@ShawK91 ShawK91 commented Jun 11, 2026

Copy link
Copy Markdown

What

Contributes to #229 by adding 21 endpoint tests for the three backend apps that currently have no test coverage: feedback, stars, and notifications (datasets, predictions, and trainings already have suites under backend/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/action filters; 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_id validation 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 with is_displayable: false; notification list requires auth and is scoped per-user; mark-read sets read_at and 404s on another user's notification; mark-all-read leaves other users' notifications untouched.

Tests follow the existing backend/tests/ conventions (pytest fixtures, APIClient.force_authenticate).

Verification

  • Full backend workflow (migrations + pytest against PostGIS) run on a fork before submitting: 154 passed, 0 failed (133 existing + the 21 added here); lint and type-check jobs also green. https://github.com/ShawK91/fAIr/actions/runs/27351994561
  • ruff check / ruff format clean on the three new files.

Developed alongside Claude Fable 5.

…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>
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.

1 participant