Close by age what an incomplete board read did not list and what a filtered read spares, so no role stays open for good, as ADR 1.3 has it
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
136047023e
commit
849adb197d
4 files changed
+62
-16
No files matched your search
@@ -250,6 +250,44 @@ def test_an_incomplete_board_stores_what_it_read_and_closes_nothing(
|
||||
assert (result["boards"], result["incomplete"], result["closed"]) == (1, 1, 0)
|
||||
|
||||
|
||||
def _aged(store: Store, source_id: str) -> None:
|
||||
"""Make a role look unlisted for longer than `STALE_DAYS`."""
|
||||
old = (datetime.now(UTC) - timedelta(days=pull.STALE_DAYS + 1)).isoformat(timespec="seconds")
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE roles SET last_seen = ? WHERE source_id = ?", (old, source_id))
|
||||
|
||||
|
||||
def test_an_incomplete_read_closes_what_no_read_has_listed_for_stale_days(
|
||||
acme: Store, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""A board past its ceiling or page cap is never read complete; a role
|
||||
it has not listed for three weeks still closes (ADR 1.3)."""
|
||||
_answer(monkeypatch, ([_row("1"), _row("2"), _row("3")], True))
|
||||
_pull(acme)
|
||||
_aged(acme, "workable:acme:3")
|
||||
_answer(monkeypatch, ([_row("1")], False))
|
||||
result = _pull(acme)
|
||||
# 2 was listed two pulls ago and stays; 3 has been unlisted for 22 days.
|
||||
assert _open(acme) == {"workable:acme:1", "workable:acme:2"}
|
||||
assert (result["incomplete"], result["closed"]) == (1, 1)
|
||||
|
||||
|
||||
def test_a_filtered_read_closes_a_spared_role_once_it_is_stale(
|
||||
acme: Store, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""A filtered read spares a role acted on from its list; after three
|
||||
weeks unlisted the role closes by age like any other."""
|
||||
_answer(monkeypatch, ([_row("1"), _row("2")], True))
|
||||
_pull(acme)
|
||||
uid = {r.source_id: r.uid for r in acme.roles()}
|
||||
agent = acme.save_agent("Hunt")
|
||||
acme.set_vote(agent.id, uid["workable:acme:2"], 1)
|
||||
_answer(monkeypatch, ([_row("1")], True), filtered=True)
|
||||
assert _pull(acme)["closed"] == 0
|
||||
assert _open(acme) == {"workable:acme:1", "workable:acme:2"}
|
||||
_aged(acme, "workable:acme:2")
|
||||
assert _pull(acme)["closed"] == 1
|
||||
assert _open(acme) == {"workable:acme:1"}
|
||||
|
||||
|
||||
def test_a_failing_board_keeps_its_roles_before_stale_days(
|
||||
acme: Store, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
_answer(monkeypatch, ([_row("1")], True))
|
||||
|
||||
Reference in new issue
Block a user