54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
"""Post-transaction authority classification for exact terminal results."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from testing.tests.test_hermes_cli_support import (
|
|
SimpleNamespace,
|
|
lanes,
|
|
nullcontext,
|
|
pytest,
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("status", "current_run_id", "expected"),
|
|
[
|
|
("running", 17, "pending"),
|
|
("running", 18, "stale"),
|
|
("ready", None, "stale"),
|
|
("blocked", None, "stale"),
|
|
("triage", None, "stale"),
|
|
],
|
|
)
|
|
def test_failed_completion_is_pending_only_for_the_exact_live_run(
|
|
status: str,
|
|
current_run_id: int | None,
|
|
expected: str,
|
|
):
|
|
task = SimpleNamespace(
|
|
id="t_authority",
|
|
status=status,
|
|
current_run_id=current_run_id,
|
|
completed_run_id=None,
|
|
result=None,
|
|
)
|
|
|
|
class Connection:
|
|
def close(self):
|
|
return None
|
|
|
|
database = SimpleNamespace(
|
|
scoped_current_board=lambda _board: nullcontext(),
|
|
connect=lambda board: Connection(),
|
|
get_task=lambda _conn, _task_id: task,
|
|
complete_task=lambda *_args, **_kwargs: False,
|
|
)
|
|
|
|
outcome = lanes._finalize_document_db(
|
|
database,
|
|
lanes.TerminalIdentity("cassandra", "t_authority", 17, "pending"),
|
|
{"result": "accepted", "summary": "accepted", "metadata": {}},
|
|
)
|
|
|
|
assert outcome == expected
|