Files
jobboard/pipeline/tests/scheduled_handlers.py
T
WolfandClaude Opus 5.5 9d666d0937 Bring in pipeline, auth, deploy and docs from the boilerplate
roledesk is built on the boilerplate from here on: pipeline 2.0 (queue and
scheduler), auth (one password, sessions, passkeys), the deploy kit and its
docs, plus the coupling and packaging tests. Downstream copies, unedited.

Refreshed from boilerplate/d56949f7d0f6c0bfe5745478e09007bfad67ae87

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 12:29:16 +02:00

40 lines
1.5 KiB
Python

"""A job and a declared schedule, in a module a worker process can import.
Not a test file — pytest does not collect it — and separate from the tests that
use it for the same reason `isolated_handlers.py` is: the process under test is
a *different* process, and it gets nothing from this one. It imports this by
the name in `--bootstrap`, which fills `JOBS` and `SCHEDULES` exactly as an
app's own jobs module does.
Separate from `isolated_handlers.py` as well, because importing a module that
calls `declare` fills a global: a test suite that imported this one would find
its own schedule registry non-empty before it had declared anything.
"""
from __future__ import annotations
from pathlib import Path
from typing import Any
from pipeline import NULL, RunContext, declare, job
@job("sw_mark", "Leaving a mark")
def sw_mark(config: Any, store: Any, *, context: RunContext = NULL) -> dict[str, Any]:
"""Touch a file in the store directory, so the parent process can see from
outside whether this ran at all."""
(Path(store) / "fired").touch()
return {"fired": True}
#: The declaration itself is what one half of the worker test is about: a
#: worker with no web app around it reconciles declared defaults like any
#: other, so a machine running only `python -m pipeline.worker` still gets
#: them.
declare("marker", "sw_mark", "every 1h", label="Leaving a mark, hourly")
def marking(marks: str) -> tuple[Any, Any]:
"""The bootstrap `pipeline.worker` is given: the marks directory is the store."""
return {}, marks