feat(server): extend GET /box/info with mixed items and attachment summary

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-08-12 14:18:56 +08:00
parent 4d55420958
commit 5b2106b30d
3 changed files with 121 additions and 2 deletions

View File

@@ -226,3 +226,33 @@ def test_attachment_box_delete_cleans_empty_box(client: TestClient, db: Session)
},
)
assert recreated.status_code == 200
def test_box_info_includes_attachment_summary(client: TestClient, db: Session):
cert_id, extra_id = _seed(db)
client.put(
"/CargoTrace/attachment/config",
json={
"zongpai_no": "26BW0011",
"determination": "has",
"items": [
{"category_id": cert_id, "expected_qty": 80},
{"category_id": extra_id, "expected_qty": 5},
],
},
)
client.post(
"/CargoTrace/attachment/box",
json={
"zongpai_no": "26BW0011",
"category_id": cert_id,
"box_no": 951,
"quantity": 80,
},
)
info = client.get(
"/CargoTrace/box/info", params={"zongpai_no": "26BW0011"}
).json()
assert info["attachment_summary"]["determination"] == "has"
assert info["attachment_summary"]["all_complete"] is False
assert info["attachment_summary"]["pending_count"] == 1 # extra not yet boxed