aboutsummaryrefslogtreecommitdiff
path: root/jb/views/tasks.py
diff options
context:
space:
mode:
authorMax Nanis2026-02-24 17:26:15 -0500
committerMax Nanis2026-02-24 17:26:15 -0500
commit8c1940445503fd6678d0961600f2be81622793a2 (patch)
treeb9173562b8824b5eaa805e446d9d780e1f23fb2a /jb/views/tasks.py
parent25d8c3c214baf10f6520cc1351f78473150e5d7a (diff)
downloadamt-jb-8c1940445503fd6678d0961600f2be81622793a2.tar.gz
amt-jb-8c1940445503fd6678d0961600f2be81622793a2.zip
Extensive use of type checking. Movement of pytest conf towards handling managers (for db agnostic unittest). Starting to organize pytests.
Diffstat (limited to 'jb/views/tasks.py')
-rw-r--r--jb/views/tasks.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/jb/views/tasks.py b/jb/views/tasks.py
index 7176b29..313295f 100644
--- a/jb/views/tasks.py
+++ b/jb/views/tasks.py
@@ -18,18 +18,23 @@ def process_request(request: Request) -> None:
amt_assignment_id = request.query_params.get("assignmentId", None)
if amt_assignment_id == "ASSIGNMENT_ID_NOT_AVAILABLE":
raise ValueError("shouldn't happen")
+
amt_hit_id = request.query_params.get("hitId", None)
amt_worker_id = request.query_params.get("workerId", None)
print(f"process_request: {amt_assignment_id=} {amt_worker_id=} {amt_hit_id=}")
assert amt_worker_id and amt_hit_id and amt_assignment_id
# Check that the HIT is still valid
- hit = HM.get_from_amt_id(amt_hit_id=amt_hit_id)
+ hit = HM.get_from_amt_id_if_exists(amt_hit_id=amt_hit_id)
+ 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)
emit_assignment_event(
status=AssignmentStatus.Accepted,
amt_hit_type_id=hit.amt_hit_type_id,
)
+
# I think it won't be assignable anymore? idk
# assert hit_status == HitStatus.Assignable, f"hit {amt_hit_id} {hit_status=}. Expected Assignable"
@@ -53,7 +58,7 @@ def process_request(request: Request) -> None:
assert assignment_stub.amt_worker_id == amt_worker_id
assert assignment_stub.amt_assignment_id == amt_assignment_id
assert assignment_stub.created_at > (
- datetime.now(tz=timezone.utc) - timedelta(minutes=90)
+ datetime.now(tz=timezone.utc) - timedelta(minutes=90)
)
return None