test: cover 7 previously-untested backend API route modules #61

Merged
ilia merged 1 commits from test/backend-pytest-coverage-gaps into dev 2026-07-14 17:17:20 -05:00
Owner

Summary

  • Adds pytest coverage for metrics, click_log, role_permissions, and videos (straightforward, standard get_db-only endpoints).
  • Adds pytest coverage for pending-identifications, pending-linkages, and reported-photos — these read/write the separate auth database (DATABASE_URL_AUTH) via raw SQL against tables owned by viewer-frontend/prisma/schema-auth.prisma. Extended tests/conftest.py with a second test-DB engine/session (test_auth_db_session) that mirrors that schema via raw DDL, and wired get_auth_db into the test_client dependency overrides.
  • Ran the full suite locally (venv + local Postgres via Docker): 183 passed, 0 new failures. The 8 pre-existing failures in test_api_faces.py/test_api_jobs.py/test_api_photos.py are unrelated drift, not caused by this change.

Known gap / follow-up

  • pending_photos.py (file upload approve/reject with hash-based duplicate detection + filesystem moves) is intentionally left uncovered — it needs a dedicated filesystem-mocking strategy that felt out of scope for this pass.
  • There is currently no CI job that runs pytest tests/ at all (only docker-ci, secret-scan, skip-ci-check, e2e exist in .gitea/workflows/ci.yml), so this suite is only exercised via npm run test:backend locally today. Wiring a test-backend CI job is a good next follow-up.

Test plan

  • npm run test:backend (against a local Postgres) — 183 passed
  • No changes to e2e/, viewer-frontend/, or CI config in this PR
## Summary - Adds pytest coverage for `metrics`, `click_log`, `role_permissions`, and `videos` (straightforward, standard `get_db`-only endpoints). - Adds pytest coverage for `pending-identifications`, `pending-linkages`, and `reported-photos` — these read/write the separate auth database (`DATABASE_URL_AUTH`) via raw SQL against tables owned by `viewer-frontend/prisma/schema-auth.prisma`. Extended `tests/conftest.py` with a second test-DB engine/session (`test_auth_db_session`) that mirrors that schema via raw DDL, and wired `get_auth_db` into the `test_client` dependency overrides. - Ran the full suite locally (venv + local Postgres via Docker): 183 passed, 0 new failures. The 8 pre-existing failures in `test_api_faces.py`/`test_api_jobs.py`/`test_api_photos.py` are unrelated drift, not caused by this change. ## Known gap / follow-up - `pending_photos.py` (file upload approve/reject with hash-based duplicate detection + filesystem moves) is intentionally left uncovered — it needs a dedicated filesystem-mocking strategy that felt out of scope for this pass. - There is currently no CI job that runs `pytest tests/` at all (only `docker-ci`, `secret-scan`, `skip-ci-check`, `e2e` exist in `.gitea/workflows/ci.yml`), so this suite is only exercised via `npm run test:backend` locally today. Wiring a `test-backend` CI job is a good next follow-up. ## Test plan - [x] `npm run test:backend` (against a local Postgres) — 183 passed - [x] No changes to `e2e/`, `viewer-frontend/`, or CI config in this PR
ilia added 1 commit 2026-07-14 17:15:41 -05:00
test: cover 7 previously-untested backend API route modules
All checks were successful
CI / skip-ci-check (pull_request) Successful in 4s
CI / docker-ci (pull_request) Successful in 6s
CI / secret-scan (pull_request) Successful in 11s
CI / e2e (pull_request) Successful in 27s
2d6bbf1d13
Adds pytest coverage for metrics, click_log, role_permissions, videos,
pending-identifications, pending-linkages, and reported-photos — the
last three required extending conftest with a second (auth) test
database + DDL mirroring the Prisma schema-auth.prisma tables, since
those endpoints read/write DATABASE_URL_AUTH via raw SQL.

pending-photos.py is intentionally left uncovered for now (heavy
filesystem/hash-based duplicate-detection logic needs its own mocking
strategy) and tracked as a follow-up.
ilia merged commit fc8b47863d into dev 2026-07-14 17:17:20 -05:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ilia/punimtag#61
No description provided.