Unit tests: API server #13

Closed
opened 2026-03-05 18:45:32 -06:00 by jeremy · 0 comments
Owner

Write pytest unit tests for the API server proxy logic and group CRUD operations.

Tasks

  • Test GET /api/nodes with mocked node agent responses
  • Test GET /api/services merges responses from all 3 nodes correctly
  • Test GET /api/services handles unreachable node gracefully
  • Test GET /api/groups returns groups from groups.json
  • Test POST /api/groups creates new group and persists to file
  • Test PUT /api/groups/{id} updates existing group
  • Test DELETE /api/groups/{id} removes group from file
  • Test group ID not found returns 404
  • Mock httpx calls to node agents using respx or pytest-mock

Setup

pip install pytest pytest-asyncio httpx respx pytest-mock
pytest tests/ -v --cov=app
Write pytest unit tests for the API server proxy logic and group CRUD operations. ## Tasks - [ ] Test `GET /api/nodes` with mocked node agent responses - [ ] Test `GET /api/services` merges responses from all 3 nodes correctly - [ ] Test `GET /api/services` handles unreachable node gracefully - [ ] Test `GET /api/groups` returns groups from groups.json - [ ] Test `POST /api/groups` creates new group and persists to file - [ ] Test `PUT /api/groups/{id}` updates existing group - [ ] Test `DELETE /api/groups/{id}` removes group from file - [ ] Test group ID not found returns 404 - [ ] Mock httpx calls to node agents using respx or pytest-mock ## Setup ``` pip install pytest pytest-asyncio httpx respx pytest-mock pytest tests/ -v --cov=app ```
jeremy added this to the v1.0 milestone 2026-03-05 18:45:32 -06:00
jeremy added the testing label 2026-03-05 18:45:32 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jeremy/farm-manager#13