fix(tests): align stale tests with current API + bypass identity-map cache

- test_recipes: split update test into in-place vs copy-on-write paths
  (PUT now updates in-place when current version has no measurements).
  Added _seed_measurement() helper to force copy-on-write where needed.
- test_tasks::reorder: expunge_all() between POST and GET so the shared
  test session re-fetches RecipeVersion.tasks instead of returning the
  cached collection. Prod uses one session per request, so identity-map
  staleness only affects tests.
- test_measure::save_measurement_proxy: payload aligned to current API
  (version_id is required; pass_fail/deviation are computed server-side).

All 179 tests green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 17:07:32 +02:00
parent 6a8931e108
commit fb96bad000
3 changed files with 85 additions and 25 deletions
+3 -5
View File
@@ -61,7 +61,7 @@ class TestSaveMeasurement:
mock_api_client.post.return_value = {
"id": 1,
"subtask_id": 10,
"task_id": 5,
"version_id": 3,
"value": 9.95,
"pass_fail": "pass",
}
@@ -70,10 +70,8 @@ class TestSaveMeasurement:
"/measure/save-measurement",
json={
"subtask_id": 10,
"task_id": 5,
"version_id": 3,
"value": 9.95,
"pass_fail": "pass",
"deviation": 0.05,
},
content_type="application/json",
)
@@ -86,7 +84,7 @@ class TestSaveMeasurement:
"""Missing required fields return 400."""
resp = logged_in_client.post(
"/measure/save-measurement",
json={"subtask_id": 10}, # missing task_id and value
json={"subtask_id": 10}, # missing version_id and value
content_type="application/json",
)
assert resp.status_code == 400