test: fix stale activate-guard test + time-fragile grace-window test

- The activate test asserted the old 'no project set' guard; activate now
  needs a project OR a product (coordination tasks carry only a product), so
  it raises only when BOTH are absent. Renamed, set product_id=None, and match
  the current 'no project or product' message.
- The grace-window test used a module-load _FRESH timestamp, but the grace
  check uses wall-clock now(), so _FRESH aged out of the window during a long
  full-suite run and flaked. Compute 'fresh' at test time.
This commit is contained in:
Renn F
2026-06-03 08:46:50 +02:00
parent 93c46d86e7
commit 5f61ea7b82
2 changed files with 13 additions and 11 deletions
@@ -83,11 +83,10 @@ def test_blocked_task_non_cell_team_unassigned_is_unroutable() -> None:
# ---------------------------------------------------------------------------
# _claimed_task_needs_agent (#19)
# _claimed_task_needs_agent — claimed-but-no-agent detection
# ---------------------------------------------------------------------------
_STALE = (datetime.now(UTC) - timedelta(minutes=30)).isoformat()
_FRESH = datetime.now(UTC).isoformat()
def test_claimed_task_with_no_agent_past_grace_returns_assignee() -> None:
@@ -119,7 +118,10 @@ def test_claimed_task_within_grace_window_is_skipped() -> None:
"id": "t1",
"status": "claimed",
"assigned_to": AGENT_UUIDS["be-dev-1"],
"updated_at": _FRESH,
# Compute "fresh" at test time, not module load: the grace check uses
# wall-clock now(), so a module-level constant ages out of the window
# during a long full-suite run and flakes this assertion.
"updated_at": datetime.now(UTC).isoformat(),
}
# Fresh claim — spawn may still be in flight; do not churn.
assert orch._claimed_task_needs_agent(task) is None