No automated tests #10

Closed
opened 2026-07-28 21:02:20 +00:00 by paulloth1 · 1 comment
paulloth1 commented 2026-07-28 21:02:20 +00:00 (Migrated from github.com)

Problem

There are no tests anywhere in the repo — no unit tests for db.py/rotation.py/slide render()/is_available() functions, no integration test hitting the FastAPI app (e.g. via httpx.AsyncClient + ASGI transport, or TestClient), nothing for the /proxy HTML-rewriting logic.

Given how much of this app's correctness depends on subtle async/state behavior (rotation loop, forced-slide interruption, the multi-process state issue in #1, the proxy regex rewrites in #5), even a small test suite would catch regressions that are currently only found by manually poking the live kiosk.

Suggested fix

Start with the cheapest-to-test, highest-value pieces:

  • backend/db.py CRUD functions against a temp SQLite file.
  • rotation.py's RotationState (forced request/take, interruptible_sleep, snapshot timing) — pure asyncio, no I/O, easy to unit test.
  • /proxy's HTML rewriting functions (script stripping, theme link swap, cookie banner CSS) against fixed sample HTML strings.
## Problem There are no tests anywhere in the repo — no unit tests for `db.py`/`rotation.py`/slide `render()`/`is_available()` functions, no integration test hitting the FastAPI app (e.g. via `httpx.AsyncClient` + ASGI transport, or `TestClient`), nothing for the `/proxy` HTML-rewriting logic. Given how much of this app's correctness depends on subtle async/state behavior (rotation loop, forced-slide interruption, the multi-process state issue in #1, the proxy regex rewrites in #5), even a small test suite would catch regressions that are currently only found by manually poking the live kiosk. ## Suggested fix Start with the cheapest-to-test, highest-value pieces: - `backend/db.py` CRUD functions against a temp SQLite file. - `rotation.py`'s `RotationState` (forced request/take, interruptible_sleep, snapshot timing) — pure asyncio, no I/O, easy to unit test. - `/proxy`'s HTML rewriting functions (script stripping, theme link swap, cookie banner CSS) against fixed sample HTML strings.
paulloth1 commented 2026-07-28 21:23:05 +00:00 (Migrated from github.com)

Fixed in aff4ef0 (merged to main at 9960e8c): added the project's first test suite — 14 tests for backend/db.py (CRUD round-trips, move_slide boundary behavior, settings upsert) and 8 for rotation.py's RotationState (snapshot/countdown math, forced-slide request/take, interruptible_sleep). All 22 pass. See requirements-dev.txt + pytest.ini for how to run them.

Fixed in aff4ef0 (merged to main at 9960e8c): added the project's first test suite — 14 tests for backend/db.py (CRUD round-trips, move_slide boundary behavior, settings upsert) and 8 for rotation.py's RotationState (snapshot/countdown math, forced-slide request/take, interruptible_sleep). All 22 pass. See requirements-dev.txt + pytest.ini for how to run them.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
paul_loth/krautspaceTV#10
No description provided.