File di riferimento rimossi con il task, immagini animate rifiutate, filtro production_run_id (#43)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 11:27:23 +02:00
parent 97c49f2b5b
commit 70e2072b79
6 changed files with 197 additions and 15 deletions
+5 -7
View File
@@ -386,14 +386,12 @@ def task_complete(recipe_id: int):
# Load measurements if version_id provided
measurements = []
if version_id:
# Scoped to this measurement session, not the whole version (#30): a
# second production run on the same recipe version used to pull in
# every other station's/day's readings too. GET /api/measurements has
# no production_run_id filter yet (that's lotto A3), so lot/serial +
# the current operator is the closest available identity - MANCA:
# once the backend accepts production_run_id, prefer it when the
# active run is known (see _current_run_id()).
# Scoped to this measurement session, not the whole version (#30): the
# active production run when known, else lot/serial + current operator.
params = {"version_id": version_id, "per_page": 500}
run_id = _current_run_id()
if run_id:
params["production_run_id"] = run_id
if lot_number:
params["lot_number"] = lot_number
if serial_number:
+27 -5
View File
@@ -338,6 +338,7 @@ class TestTaskComplete:
# The summary serialises the version number, so the recipe carries one.
{"id": 1, "code": "REC-001", "name": "Test Recipe", "version": 1},
[{"id": 1, "title": "Task 1", "order_index": 0, "subtasks": []}],
None, # current run
{"items": []}, # measurements
]
@@ -357,13 +358,14 @@ class TestTaskComplete:
mock_api_client.get.side_effect = [
{"id": 1, "code": "REC-001", "name": "Test Recipe", "version": 1},
[{"id": 1, "title": "Task 1", "order_index": 0, "subtasks": []}],
None, # current run
{"items": [], "pages": 1},
]
resp = logged_in_client.get("/measure/complete/1?version_id=5")
assert resp.status_code == 200
endpoint, kwargs = mock_api_client.get.call_args_list[2]
endpoint, kwargs = mock_api_client.get.call_args_list[3]
assert endpoint[0] == "/api/measurements"
params = kwargs["params"]
assert params["version_id"] == "5"
@@ -371,6 +373,24 @@ class TestTaskComplete:
assert params["serial_number"] == "S1"
assert params["measured_by"] == 1 # session["user_id"] from the fixture
def test_measurements_filtered_by_the_active_production_run(
self, logged_in_client, mock_api_client,
):
"""#43: when the station has a run open, the summary asks for that run."""
mock_api_client.get.side_effect = [
{"id": 1, "code": "REC-001", "name": "Test Recipe", "version": 1},
[{"id": 1, "title": "Task 1", "order_index": 0, "subtasks": []}],
{"id": 77}, # current run
{"items": [], "pages": 1},
]
resp = logged_in_client.get("/measure/complete/1?version_id=5")
assert resp.status_code == 200
endpoint, kwargs = mock_api_client.get.call_args_list[3]
assert endpoint[0] == "/api/measurements"
assert kwargs["params"]["production_run_id"] == 77
def test_measurements_without_lot_or_serial_still_scope_to_the_operator(
self, logged_in_client, mock_api_client,
):
@@ -379,13 +399,14 @@ class TestTaskComplete:
mock_api_client.get.side_effect = [
{"id": 1, "code": "REC-001", "name": "Test Recipe", "version": 1},
[{"id": 1, "title": "Task 1", "order_index": 0, "subtasks": []}],
None, # current run
{"items": [], "pages": 1},
]
resp = logged_in_client.get("/measure/complete/1?version_id=5")
assert resp.status_code == 200
endpoint, kwargs = mock_api_client.get.call_args_list[2]
endpoint, kwargs = mock_api_client.get.call_args_list[3]
params = kwargs["params"]
assert "lot_number" not in params
assert "serial_number" not in params
@@ -404,15 +425,16 @@ class TestTaskComplete:
mock_api_client.get.side_effect = [
{"id": 1, "code": "REC-001", "name": "Test Recipe", "version": 1},
[{"id": 1, "title": "Task 1", "order_index": 0, "subtasks": [subtask]}],
None, # current run
page1,
page2,
]
resp = logged_in_client.get("/measure/complete/1?version_id=5")
assert resp.status_code == 200
assert mock_api_client.get.call_count == 4
first_page_call = mock_api_client.get.call_args_list[2]
second_page_call = mock_api_client.get.call_args_list[3]
assert mock_api_client.get.call_count == 5
first_page_call = mock_api_client.get.call_args_list[3]
second_page_call = mock_api_client.get.call_args_list[4]
assert first_page_call.kwargs["params"]["page"] == 1
assert second_page_call.kwargs["params"]["page"] == 2