From dadd9643feceac94a2b84d9a3d3dda667f17583d Mon Sep 17 00:00:00 2001 From: Max Nanis Date: Thu, 26 Feb 2026 21:20:14 -0500 Subject: check_hit_status to use manager param, and amt_stub_context usage in flow tests. --- jb/flow/maintenance.py | 7 +++++-- jb/views/tasks.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'jb') diff --git a/jb/flow/maintenance.py b/jb/flow/maintenance.py index 744ed1d..f8ca971 100644 --- a/jb/flow/maintenance.py +++ b/jb/flow/maintenance.py @@ -7,7 +7,10 @@ from jb.models.definitions import HitStatus def check_hit_status( - amt_hit_id: str, amt_hit_type_id: str, reason: Optional[str] = None + amtm: AMTManager, + amt_hit_id: str, + amt_hit_type_id: str, + reason: Optional[str] = None, ) -> HitStatus: """ (this used to be called "process_hit") @@ -15,7 +18,7 @@ def check_hit_status( the local state from that response. """ - hit_status = AMTManager.get_hit_status(amt_hit_id=amt_hit_id) + hit_status = amtm.get_hit_status(amt_hit_id=amt_hit_id) # We're assuming that in the db this Hit is marked as Assignable, or # else we wouldn't have called this function. diff --git a/jb/views/tasks.py b/jb/views/tasks.py index 313295f..15857c3 100644 --- a/jb/views/tasks.py +++ b/jb/views/tasks.py @@ -2,7 +2,7 @@ from datetime import datetime, timezone, timedelta from fastapi import Request -from jb.decorators import AM, HM +from jb.decorators import AMTM, AM, HM from jb.flow.maintenance import check_hit_status from jb.flow.monitoring import emit_assignment_event from jb.models.assignment import AssignmentStub @@ -29,7 +29,10 @@ def process_request(request: Request) -> None: if not hit: raise ValueError(f"Hit {amt_hit_id} not found in DB") - _ = check_hit_status(amt_hit_id=amt_hit_id, amt_hit_type_id=hit.amt_hit_type_id) + _ = check_hit_status( + amtm=AMTM, amt_hit_id=amt_hit_id, amt_hit_type_id=hit.amt_hit_type_id + ) + emit_assignment_event( status=AssignmentStatus.Accepted, amt_hit_type_id=hit.amt_hit_type_id, -- cgit v1.2.3