Sprint 6: report review workflow, CI/K8s, and client tabs.
CI / api-test (push) Has been cancelled
CI / web-build (push) Has been cancelled

Add coach review APIs, pose calibration thresholds, Gitea CI, Kubernetes skeleton, H5 practice page, and mini program tab bar.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-23 11:44:11 +08:00
parent 1aaef71f52
commit a400130c67
27 changed files with 636 additions and 27 deletions
+33
View File
@@ -44,3 +44,36 @@ def auth_headers(client):
assert resp.status_code == 200, resp.text
token = resp.json()["data"]["token"]
return {"Authorization": f"Bearer {token}"}
@pytest.fixture()
def staff_headers(client, db_session):
from sqlalchemy import select
from app.core.security import hash_phone
from app.db.models import User
resp = client.post(
"/api/auth/login",
json={"loginType": "phone_code", "credential": "18600000001", "code": "682139"},
)
assert resp.status_code == 200, resp.text
token = resp.json()["data"]["token"]
user = db_session.scalar(select(User).where(User.phone_hash == hash_phone("18600000001")))
if user:
user.role = "coach"
db_session.commit()
return {"Authorization": f"Bearer {token}"}
@pytest.fixture()
def db_session(client):
gen = app.dependency_overrides[get_db]()
db = next(gen)
try:
yield db
finally:
try:
next(gen)
except StopIteration:
pass
+1 -1
View File
@@ -4,7 +4,7 @@ from fastapi.testclient import TestClient
def test_health(client):
resp = client.get("/health")
assert resp.status_code == 200
assert resp.json()["stage"] == "sprint5"
assert resp.json()["stage"] == "sprint6"
def test_login_invalid_code(client):
+63
View File
@@ -0,0 +1,63 @@
def test_review_required_risk_level():
from app.ai.pose_metrics import LEFT_HIP, LEFT_SHOULDER, NOSE, RIGHT_HIP, RIGHT_SHOULDER, build_screening_report
bad_frame = {
NOSE: {"x": 0.85, "y": 0.28, "visibility": 0.95},
LEFT_SHOULDER: {"x": 0.42, "y": 0.35, "visibility": 0.95},
RIGHT_SHOULDER: {"x": 0.58, "y": 0.48, "visibility": 0.95},
LEFT_HIP: {"x": 0.44, "y": 0.62, "visibility": 0.95},
RIGHT_HIP: {"x": 0.56, "y": 0.50, "visibility": 0.95},
}
report = build_screening_report([bad_frame] * 6)
assert report["riskLevel"] == "review_required"
def test_admin_report_review_flow(client, auth_headers, staff_headers, db_session):
from app.db.models import Report
child_id = client.post(
"/api/children",
headers=auth_headers,
json={"name": "复核测试", "birthday": "2016-06-01", "gender": "female"},
).json()["data"]["id"]
object_key = f"videos/{child_id}/review.mp4"
video_id = client.post(
"/api/videos",
headers=auth_headers,
json={"childId": child_id, "objectKey": object_key, "scene": "front_posture"},
).json()["data"]["id"]
task = client.post(
"/api/analysis/tasks",
headers={**auth_headers, "Idempotency-Key": "sprint6-review"},
json={"childId": child_id, "videoId": video_id, "taskType": "posture_screening"},
).json()["data"]
report_id = task["reportId"]
assert report_id
report = db_session.get(Report, report_id)
report.status = "pending_review"
report.risk_level = "high"
db_session.commit()
pending = client.get("/api/admin/reports/pending", headers=staff_headers)
assert pending.status_code == 200
assert any(item["id"] == report_id for item in pending.json()["data"]["list"])
approved = client.post(
f"/api/admin/reports/{report_id}/review",
headers=staff_headers,
json={"action": "approve", "note": "指标可接受,发布报告"},
)
assert approved.status_code == 200
assert approved.json()["data"]["status"] == "published"
assert approved.json()["data"]["reviewedBy"]
detail = client.get(f"/api/reports/{report_id}", headers=auth_headers)
assert detail.json()["data"]["status"] == "published"
def test_health_sprint6(client):
resp = client.get("/health")
assert resp.json()["stage"] == "sprint6"