tests/test_integrity_wp15.py hinzugefügt
All checks were successful
Deploy Trainer_LLM to llm-node / deploy (push) Successful in 1s
All checks were successful
Deploy Trainer_LLM to llm-node / deploy (push) Successful in 1s
This commit is contained in:
parent
ff58caaad0
commit
ed05448e56
93
tests/test_integrity_wp15.py
Normal file
93
tests/test_integrity_wp15.py
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Integritätstests für Referenzen (Templates, Exercises, Plans)."""
|
||||
import os, requests, uuid
|
||||
from datetime import datetime, timezone
|
||||
|
||||
BASE = os.getenv("BASE_URL", "http://127.0.0.1:8000").rstrip("/")
|
||||
|
||||
|
||||
def _make_exercise(ext_id: str):
|
||||
payload = {
|
||||
"external_id": ext_id,
|
||||
"fingerprint": "it-sha",
|
||||
"source": "IntegrityTest",
|
||||
"title": "Übung Dummy",
|
||||
"summary": "",
|
||||
"short_description": "",
|
||||
"keywords": ["Reaktion"],
|
||||
"discipline": "Karate",
|
||||
"age_group": "Teenager",
|
||||
"target_group": "Breitensport",
|
||||
"min_participants": 1,
|
||||
"duration_minutes": 5,
|
||||
"capabilities": {"Reaktionsfähigkeit": 1},
|
||||
"category": "Übungen",
|
||||
"purpose": "",
|
||||
"execution": "",
|
||||
"notes": "",
|
||||
"preparation": "",
|
||||
"method": "",
|
||||
"equipment": []
|
||||
}
|
||||
r = requests.post(f"{BASE}/exercise", json=payload)
|
||||
assert r.status_code == 200, r.text
|
||||
|
||||
|
||||
def test_plan_requires_existing_template():
|
||||
# Übung anlegen für gültigen Plan (damit Exercise-Check nicht stört)
|
||||
exid = f"it:{uuid.uuid4()}"; _make_exercise(exid)
|
||||
|
||||
# Plan mit nicht existenter template_id
|
||||
plan = {
|
||||
"template_id": "does-not-exist",
|
||||
"title": "Plan mit falschem Template",
|
||||
"discipline": "Karate",
|
||||
"age_group": "Teenager",
|
||||
"target_group": "Breitensport",
|
||||
"total_minutes": 30,
|
||||
"sections": [{"name": "Block", "minutes": 30, "items": [{"exercise_external_id": exid, "duration": 10, "why": ""}]}],
|
||||
"goals": [],
|
||||
"capability_summary": {},
|
||||
"created_by": "tester",
|
||||
"created_at": datetime.now(timezone.utc).isoformat(),
|
||||
"source": "test"
|
||||
}
|
||||
r = requests.post(f"{BASE}/plan", json=plan)
|
||||
assert r.status_code == 422
|
||||
|
||||
|
||||
def test_plan_session_requires_existing_plan():
|
||||
sess = {
|
||||
"plan_id": "does-not-exist",
|
||||
"executed_at": datetime.now(timezone.utc).isoformat(),
|
||||
"location": "Dojo",
|
||||
"coach": "X",
|
||||
"group_label": "Y",
|
||||
"feedback": {"rating": 3, "notes": ""},
|
||||
"used_equipment": []
|
||||
}
|
||||
r = requests.post(f"{BASE}/plan_sessions", json=sess)
|
||||
assert r.status_code == 422
|
||||
|
||||
|
||||
def test_strict_exercises_if_env():
|
||||
# Nur sinnvoll, wenn Server mit PLAN_STRICT_EXERCISES=1 gestartet wurde
|
||||
if os.getenv("PLAN_STRICT_EXERCISES") not in {"1", "true", "yes", "on"}:
|
||||
import pytest; pytest.skip("Strict-Mode nicht aktiv – Test übersprungen")
|
||||
|
||||
plan = {
|
||||
"title": "Plan mit unbekannter Übung",
|
||||
"discipline": "Karate",
|
||||
"age_group": "Teenager",
|
||||
"target_group": "Breitensport",
|
||||
"total_minutes": 10,
|
||||
"sections": [{"name": "Block", "minutes": 10, "items": [{"exercise_external_id": "unknown:xyz", "duration": 5, "why": ""}]}],
|
||||
"goals": [],
|
||||
"capability_summary": {},
|
||||
"created_by": "tester",
|
||||
"created_at": datetime.now(timezone.utc).isoformat(),
|
||||
"source": "test"
|
||||
}
|
||||
r = requests.post(f"{BASE}/plan", json=plan)
|
||||
assert r.status_code == 422
|
||||
Loading…
Reference in New Issue
Block a user