Unit tests: Node agent #12

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

Write pytest unit tests for the node agent with a mocked Docker socket.

Tasks

  • Test GET /health returns 200 with node info
  • Test GET /containers returns correct container list format
  • Test POST /containers/{id}/start calls docker.containers.get().start()
  • Test POST /containers/{id}/stop calls docker.containers.get().stop()
  • Test POST /containers/{id}/restart calls docker.containers.get().restart()
  • Test GET /containers/{id}/logs returns log lines
  • Test 404 when container ID not found
  • Mock docker SDK using unittest.mock or pytest-mock
  • Achieve >80% code coverage

Setup

pip install pytest pytest-asyncio httpx pytest-mock
pytest tests/ -v --cov=app
Write pytest unit tests for the node agent with a mocked Docker socket. ## Tasks - [ ] Test `GET /health` returns 200 with node info - [ ] Test `GET /containers` returns correct container list format - [ ] Test `POST /containers/{id}/start` calls docker.containers.get().start() - [ ] Test `POST /containers/{id}/stop` calls docker.containers.get().stop() - [ ] Test `POST /containers/{id}/restart` calls docker.containers.get().restart() - [ ] Test `GET /containers/{id}/logs` returns log lines - [ ] Test 404 when container ID not found - [ ] Mock docker SDK using unittest.mock or pytest-mock - [ ] Achieve >80% code coverage ## Setup ``` pip install pytest pytest-asyncio httpx pytest-mock pytest tests/ -v --cov=app ```
jeremy added this to the v1.0 milestone 2026-03-05 18:45:31 -06:00
jeremy added the testing label 2026-03-05 18:45:31 -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#12