Download backend/scripts/verify_full_system.py from YVES28/lerningOs: direct link, hf CLI and curl.
- Browser
- Download file 2.69 kB
-
https://huggingface.co/spaces/YVES28/lerningOs/resolve/main/backend/scripts/verify_full_system.py
- Command line
-
hf download hf://spaces/YVES28/lerningOs/backend/scripts/verify_full_system.py
-
curl -L -o verify_full_system.py https://huggingface.co/spaces/YVES28/lerningOs/resolve/main/backend/scripts/verify_full_system.py
2.69 kB
| import time | |
| import requests | |
| import json | |
| import logging | |
| logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") | |
| logger = logging.getLogger("SystemVerifier") | |
| BASE_URL = "http://localhost:8000" | |
| def test_full_system_lifecycle(): | |
| logger.info("=== [Verification Step 1] Health Check & Metrics Readiness ===") | |
| r = requests.get(f"{BASE_URL}/health") | |
| assert r.status_code == 200, f"Health check failed: {r.text}" | |
| logger.info(f"Health Status: {r.json()}") | |
| logger.info("\n=== [Verification Step 2] Commercial Tenant Quota & Billing ===") | |
| start_payload = {"child_id": "00000000-0000-0000-0000-000000000001"} | |
| r = requests.post(f"{BASE_URL}/api/v1/commercial/assessments/start", json=start_payload) | |
| assert r.status_code == 200, f"Billing start failed: {r.text}" | |
| session_data = r.json() | |
| logger.info(f"Commercial Assessment Session Started: {session_data}") | |
| logger.info("\n=== [Verification Step 3] CAT 2PL IRT Next-Item Generation ===") | |
| session_id = session_data["session_id"] | |
| next_item_url = f"{BASE_URL}/api/v1/assessments/sessions/{session_id}/next-item?dimension=attention" | |
| t0 = time.time() | |
| r = requests.get(next_item_url) | |
| latency_ms = (time.time() - t0) * 1000 | |
| logger.info(f"CAT Next-Item Fetched in {latency_ms:.2f} ms | Status: {r.status_code}") | |
| assert r.status_code in [200, 404] | |
| logger.info("\n=== [Verification Step 4] Offline Batch Sync & Idempotency ===") | |
| sync_payload = { | |
| "tenant_id": "tenant_default", | |
| "child_id": "00000000-0000-0000-0000-000000000001", | |
| "offline_answers": [ | |
| { | |
| "client_response_id": "resp_uuid_999", | |
| "session_id": session_id, | |
| "item_id": "item_att_01", | |
| "dimension": "attention", | |
| "user_response": {"answer": 1}, | |
| "is_correct": True, | |
| "response_time_ms": 1200, | |
| "answered_at": "2026-07-29T10:00:00Z" | |
| } | |
| ] | |
| } | |
| r = requests.post(f"{BASE_URL}/api/v1/sync/offline-answers", json=sync_payload) | |
| logger.info(f"Batch Sync Response: {r.json()}") | |
| assert r.status_code == 200 | |
| logger.info("\n=== [Verification Step 5] GDPR Right-to-be-Forgotten Execution ===") | |
| wipe_url = f"{BASE_URL}/api/v1/compliance/gdpr/forget-child/00000000-0000-0000-0000-000000000001" | |
| r = requests.delete(wipe_url) | |
| logger.info(f"GDPR Data Wipe Status: {r.status_code} | Payload: {r.json()}") | |
| assert r.status_code == 200 | |
| logger.info("\n🎉 All 12D AI Assessment Engine V1 Production Gatekeeper Checks PASSED!") | |
| if __name__ == "__main__": | |
| test_full_system_lifecycle() | |