test: add pytest infrastructure and poll() tests #4

Closed
opened 2026-07-19 08:46:10 +02:00 by peter · 0 comments
Owner

Parent

Part of #1

What to build

Add pytest and pytest-asyncio to the project's dev dependencies and write three tests that exercise poll() in isolation using injected test doubles — no real HTTP calls, no real Kafka connection.

The three tests are:

  1. Single page: given a mock HTTP session returning one page of N Flights with no pagination header, poll() publishes exactly N messages to the mock Kafka engine and returns N.
  2. Pagination: given a mock HTTP session returning two pages (the first page carries a link: rel="next" header pointing at the second), poll() publishes the combined Flight count from both pages and returns that total.
  3. HTTP error propagation: given a mock HTTP session whose get() raises an HTTP error, poll() propagates that exception to its caller.

Acceptance criteria

  • pytest and pytest-asyncio are listed in the project's dev dependencies and installable via uv sync
  • pytest can be invoked and discovers the new tests
  • All three tests pass (green)
  • Tests inject a stub HTTP session and a mock Kafka engine — no real network or broker required
  • Ruff linting passes on the new test files

Blocked by

  • #3 (prefactor: extract poll() function from start())
## Parent Part of #1 ## What to build Add `pytest` and `pytest-asyncio` to the project's dev dependencies and write three tests that exercise `poll()` in isolation using injected test doubles — no real HTTP calls, no real Kafka connection. The three tests are: 1. **Single page**: given a mock HTTP session returning one page of N Flights with no pagination header, `poll()` publishes exactly N messages to the mock Kafka engine and returns N. 2. **Pagination**: given a mock HTTP session returning two pages (the first page carries a `link: rel="next"` header pointing at the second), `poll()` publishes the combined Flight count from both pages and returns that total. 3. **HTTP error propagation**: given a mock HTTP session whose `get()` raises an HTTP error, `poll()` propagates that exception to its caller. ## Acceptance criteria - [ ] `pytest` and `pytest-asyncio` are listed in the project's dev dependencies and installable via `uv sync` - [ ] `pytest` can be invoked and discovers the new tests - [ ] All three tests pass (green) - [ ] Tests inject a stub HTTP session and a mock Kafka engine — no real network or broker required - [ ] Ruff linting passes on the new test files ## Blocked by - #3 (prefactor: extract poll() function from start())
peter added the
ready-for-agent
label 2026-07-19 08:46:10 +02:00
peter self-assigned this 2026-07-19 09:03:29 +02:00
peter closed this issue 2026-07-19 09:07:35 +02:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: peter/schiphol#4
No description provided.