Files
john 1aaef71f52 Initial commit: Happy Up monorepo through Sprint 5.
Document-driven MVP with FastAPI backend, Vue H5, WeChat mini shell, product demo, and Docker dev stack.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-23 11:42:40 +08:00

95 lines
2.7 KiB
Python

def test_screening_pipeline(client, auth_headers):
child = client.post(
"/api/children",
headers=auth_headers,
json={"name": "小红", "birthday": "2017-05-01", "gender": "female"},
).json()["data"]
child_id = child["id"]
token_resp = client.post(
"/api/videos/upload-token",
headers=auth_headers,
json={
"childId": child_id,
"fileName": "front.mp4",
"contentType": "video/mp4",
"size": 1024000,
},
)
assert token_resp.status_code == 200
object_key = token_resp.json()["data"]["objectKey"]
video_resp = client.post(
"/api/videos",
headers=auth_headers,
json={
"childId": child_id,
"objectKey": object_key,
"scene": "front_posture",
},
)
assert video_resp.status_code == 201
video_id = video_resp.json()["data"]["id"]
task_resp = client.post(
"/api/analysis/tasks",
headers={**auth_headers, "Idempotency-Key": "screening-task-1"},
json={
"childId": child_id,
"videoId": video_id,
"taskType": "posture_screening",
},
)
assert task_resp.status_code == 201
task = task_resp.json()["data"]
assert task["status"] == "SUCCEEDED"
assert task["reportId"]
dup_resp = client.post(
"/api/analysis/tasks",
headers={**auth_headers, "Idempotency-Key": "screening-task-1"},
json={
"childId": child_id,
"videoId": video_id,
"taskType": "posture_screening",
},
)
assert dup_resp.status_code == 409
report_resp = client.get(
f"/api/reports/{task['reportId']}",
headers=auth_headers,
)
assert report_resp.status_code == 200
report = report_resp.json()["data"]
assert report["riskLevel"] == "medium"
assert len(report["metrics"]) >= 3
def test_movement_report_pipeline(client, auth_headers):
child_id = client.post(
"/api/children",
headers=auth_headers,
json={"name": "小刚", "birthday": "2015-08-12", "gender": "male"},
).json()["data"]["id"]
object_key = f"videos/{child_id}/live.mp4"
video_id = client.post(
"/api/videos",
headers=auth_headers,
json={"childId": child_id, "objectKey": object_key, "scene": "side_posture"},
).json()["data"]["id"]
task = client.post(
"/api/analysis/tasks",
headers=auth_headers,
json={
"childId": child_id,
"videoId": video_id,
"taskType": "movement_scoring",
},
).json()["data"]
report = client.get(f"/api/reports/{task['reportId']}", headers=auth_headers).json()["data"]
assert report["score"] == 81