Runs is the queue's elements and a Problems log; a Kill lands between boards

Run one stage goes: the cascade is the unit of work and app job keeps the
per-stage entry points. The pull button is disabled while a pull runs and
the lede no longer hardcodes the cadence. Messages folds into Runs as
Problems. pull_batch checks for a cancel before every board, one plugin per
target, and both plugins now close their HTTP client.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-09-28 16:10:38 +02:00
1 parent cebe62ddc9
commit 8532e4e739
15 files changed
+284 -242

No files matched your search

+30
View File
@@ -16,6 +16,7 @@ if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from desk.models import Item # noqa: E402
from pipeline import Cancelled, RunContext # noqa: E402
from plugins.ats import ATSSource # noqa: E402
from app.jobs import pull # noqa: E402
from app.storage import Store # noqa: E402
@@ -81,6 +82,35 @@ def test_run_batch_upserts_every_item_the_plugin_yields(
assert store.roles()[0].subscription_id is not None
def test_a_kill_stops_the_batch_before_the_next_board(
store: Store, monkeypatch: pytest.MonkeyPatch) -> None:
"""`check()` before each board: a Kill pressed while the first is read
ends the job before the second is fetched, and keeps what the first
stored."""
for slug in ("acme", "beta"):
store.add_subscription("ats", f"greenhouse:{slug}", label=slug.title(),
company=slug.title(), board="greenhouse")
fetched: list[str] = []
killed = False
def fake_fetch(self: ATSSource) -> object:
nonlocal killed
[(target, _)] = self.targets()
fetched.append(target)
yield _item("greenhouse", target.partition(":")[2], "1")
killed = True
monkeypatch.setattr(ATSSource, "fetch", fake_fetch)
context = RunContext(is_cancelled=lambda: killed)
with pytest.raises(Cancelled):
pull.run_batch(FakeConfig(), store, targets=["greenhouse:acme", "greenhouse:beta"],
context=context)
assert fetched == ["greenhouse:acme"]
assert {r.source_id for r in store.roles()} == {"greenhouse:acme:1"}
def test_close_boards_closes_what_a_completed_board_no_longer_lists(
store: Store) -> None:
sub = store.add_subscription("ats", "greenhouse:acme", label="Acme",